I am trying to use the iTerm example shown here in answer to another query.
Basically I have a list of about 20 text files representing reports from different servers. I want to read each file name in the directory they live in and from that build a shell command that exists in a commands directory, then open a new iTerm window and then execute that shell script that I built.
I don't want to run them all in one window one after the other, I want them each to execute in their own window to speed up the processing.
Here is what I have, I can build the shell script name and store in foo quite happily and it seems I can open the new iTerm window OK too, but it is getting it to accept $foo as the command to be run I am having trouble with.
#!/bin/sh
FILES=/Volumes/reporter/uplod/lists/*
# eg each filename is of the type <path>/X07QXL29.txt
for f in $FILES
do
foo="del"
foo+=${f:32:1}
foo+=${f:36:2}
foo+=".sh"
# foo is now for example del729.sh using the above comment as the filename
# foo is the command I will want to run in its own new window
osascript <<END
tell application "iTerm"
tell the first terminal
tell myterm
launch session "Default Session"
tell the last session
write text "$foo"
write text "\n"
end tell
end tell
end tell
END
done
The error I am getting is:deltrash.sh: line 22: syntax error: unexpected end of file
Can anyone please give me a pointer?