Re: passing shell script arguments?
Re: passing shell script arguments?
- Subject: Re: passing shell script arguments?
- From: Andrew Oliver <email@hidden>
- Date: Fri, 03 Oct 2003 09:21:02 -0700
On 10/2/03 1:40 PM, "Star" <email@hidden> wrote:
>
Hi Andrew,
>
>
Thanks so much for the help, I'm dying on the vine here.
>
>
>> For a start, what is 'myShellCode' defined as?
>
>
myShellCode:
>
is the text of the shell script itself. I read it in (as text) to a property
>
of the applescript so that I don't have it laying around as a seperate
>
loose component. The shell script is huge and this part seems to
>
be working fine as it asks for the "test_file log_file" which are it's
>
arguments to look for when processing.
OK, this part makes me wonder.
If your shell script is large, surely you need to embed the file names in
the script before you pass it to the shell, no?
Consider the following vastly simplified example intended to remove all .txt
files in a given directory:
set theScript to "cd $1; rm *.txt"
set targetDir to "/var/tmp"
do shell script theScript & " " & targetDir
Instead of passing in the name of the directory to the script (as you might
expect), you end up with:
cd $1; rm *.txt /var/tmp
Which won't work.
Instead you'd need to build your script along the lines of:
set theScript to "cd " & targetDir & "; rm *.txt"
do shell script theScript
Andrew
:)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.