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?
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.