need to load a text file into applescript

Still a Applescript noob, and i’m trying to figure out how to do a repeat command with a text file as the variable.
Right now I have it so it promt you to put in an ip address, but we also have a list of ip address (can either be .txt or .rtf)

Here the current script:

set remoteHostByIP to text returned of («event panSdlog» "Please enter IP of Client:" given «class btns»:{"Cancel", "Connect"}, «class dflt»:"Connect", «class dtxt»:"") as Unicode text
	
	do shell script "/usr/bin/rsync -a -e ssh --delete ~/Music/itunes/ music@" & remoteHostByIP & ":~/Music/itunes/"
	do shell script "ssh music@" & remoteHostByIP & " killall iTunes"
	do shell script "ssh music@" & remoteHostByIP & " ~/Desktop/ituneslaunch.app/Contents/MacOS/ituneslaunch"

So instead of it using remoteHostByIP, how would i have it do this script for every ip address in the text file?

Thanks in advance :slight_smile:

well - you already pretty much have a shell script - why not make it easy and just go all the way there?

[code]#!/bin/bash

cat path/to/listofips.txt | while read FILE

do
/usr/bin/rsync -a -e ssh --delete ~/Music/itunes/ music@“$FILE” ~/Music/itunes/
ssh music@“$FILE”" killall iTunes"
ssh music@“$FILE” ~/Desktop/ituneslaunch.app/Contents/MacOS/ituneslaunch
done[/code]

That was my first though. However, here’s a possible AppleScript solution:

property AddressFile : alias ((path to home folder as Unicode text) & "IP Address List.txt")

try
	read AddressFile
	set AddressList to paragraphs of result
	
	repeat with thisAddress in AddressList
		do shell script "/usr/bin/rsync -a -e ssh --delete ~/Music/iTunes/ music@" & thisAddress & ":~/Music/iTunes/;" & ¬
			"ssh music@" & thisAddress & " 'killall iTunes; ~/Desktop/ituneslaunch.app/Contents/MacOS/ituneslaunch'"
	end repeat
on error errorMsg number errorNum
	display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
end try

The “AddressFile” should be plain text, with one address on each line.

Bruce, it worked great… much appreciated :slight_smile: