RE: Inconsistancy Between Do Shell Script and Terminal?
RE: Inconsistancy Between Do Shell Script and Terminal?
- Subject: RE: Inconsistancy Between Do Shell Script and Terminal?
- From: "de Runtz, Lars" <email@hidden>
- Date: Thu, 13 Jan 2005 05:42:49 -0800
- Thread-topic: Inconsistancy Between Do Shell Script and Terminal?
It is important to declare the shell environment, at the top of shell scripts.
#!/bin/bash
for the bourne again shell. The do shell script may actual default to another similar environment, like tcsh. Different MacOS's may default to different shells, too.
or
>From that tech note:
Q: Why doesn't do shell script work exactly like Terminal?
A: For two reasons: first, it helps guarantee that scripts will run on different systems without modification. If do shell script used your default shell or PATH, your script would probably break if you gave it to someone else. Second, it matches shell escape mechanisms in other languages, such as Perl.
Q: How do I run my command with a shell other than sh?
A: Include the shell you want to use explicitly in the command. There are a variety of ways to pass commands to your shell of choice. You could write the command to a file and then execute the file like this:
do shell script "/bin/tcsh my-command-file-path"
That sounds like what is going on there. I think I put my #!/bin/bash in my scripts because I encountered funny problems, and declaring it solved them.
Lars DeRuntz
ModusLink
Newark, CA
-----Original Message-----
From: Adam K. Wuellner [mailto:email@hidden]
Sent: Wednesday, January 12, 2005 12:36 PM
To: Jonathan Levi, M.D.
Cc: AppleScript-Users
Subject: Re: Inconsistancy Between Do Shell Script and Terminal?
> do shell script "~/bin/getMedscapeViewArticleNumber.sh
> '/office/CME/medscape-articles/cardiologyViewdocs/3221-
> childhoodObesity/3221.html'"
>
> (as copied from the Event log) returns "", while the exact command
> minus first three words and outer quotes, copied from the same log and
> pasted into a Terminal window, gives "481633
> " (i.e., with final return)?
The line of AppleScript code looks okay. There might be an issue with
the .sh script it calls.
<http://developer.apple.com/technotes/tn2002/tn2065.html> explains the
differences between the environment you get in Terminal, and the
environment you get when using do shell script ("Gory Details").
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden