• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: passing shell script arguments?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Notetaker now scriptable (and lots of example scripts)
  • Next by Date: Re: Change the Position of an disk icon on the desktop
  • Previous by thread: Re: passing shell script arguments?
  • Next by thread: Re: passing shell script arguments?
  • Index(es):
    • Date
    • Thread