Combining AppleScript variables and UNIX shell scripts

Aug 07, '03 09:25:00AM

Contributed by: Anonymous

For the past three months, I have been trying to run a shell script through an AppleScript. This is easy enough using the do shell script command, but I wanted to use a variable (entered from a dialog box) somewhere in that code. So, what i was trying to do was:

set thevariable to "bob.txt"
do shell script "ls ~/ >>~/Desktop/thevariable"

That didn't work, so I played around with it and I came up with this, which does work:

set thevariable to "bob"
set thescript to "ls ~/ >>~/Desktop/" & thevariable & ".txt."
do shell script (thescript)

Hope this helps someone...

Comments (7)

Mac OS X Hints