Issues writing Applescript loop


I am new to using AppleScript and was googling how to use Applescript to open a Terminal session and connect to a remote box using SSH.

This was successful in a single instance, using the script:
tell application “Terminal”
do script “ssh root@
– // write some linux commands to remote server
end tell

Then saving it as an application.

As this now works, the issue I have is that I have a list of box’s that I need to connect to on a regular basis (i’ve just moved from a Windows machine where I used putty) and need to create Applescripts, for each one.

I am having trouble in finding out how to use this list (currently a numbers spreadsheet) to create some kind of loop, to create individual files, for each one.

I was thinking about converting it to a csv file and the creating a script that uses the column headers:
IP address

Opens script editor, enters the same script as before, replaces the IP address, saves the script, using the naming convention Number-Name and then putting them into subfolders for each location. However as I said earlier, as I’m new to scripting in AppleScript, I’m finding it hard to trall through all the tutorials and forums for assistance.

Can anyone offer any advice?


this is a simple script which assumes a file data.csv on desktop.
This file contains comma separated lines as you specified for example,128,John Doe,/Users/John/Documents/
The script reads the file and assigns the fields to variables of each line in a repeat loop.
Hope it helps

set csvFile to (path to desktop as text) & "data.csv"
set theRecords to paragraphs of (read file csvFile)
set {TID, text item delimiters} to {text item delimiters, ","}
repeat with aRecord in theRecords
	set {ipAddress, aNumber, aName, aLocation} to text items of aRecord
	do shell script "ssh root@" & ipAddress
end repeat
set text item delimiters to TID