Re: Ping with AS under OS X?
Re: Ping with AS under OS X?
- Subject: Re: Ping with AS under OS X?
- From: John W Baxter <email@hidden>
- Date: Mon, 20 May 2002 19:32:42 -0700
At 17:54 +0100 5/20/2002, Christopher Nebel wrote:
>
The problem you're having is because "do shell script" (or more
>
precisely, the sh process it spawns) uses a very restricted PATH to
>
locate commands. Say "/sbin/ping" instead, and it'll work.
<Podium_mode>
Discard this message now if you don't care about do shell script.
We've spoken here several times about "a very restricted PATH" and the Unix
folks have understood.
A little background, using the ping command because it's the recent
one...chown would do as well).
First...the executable ping doesn't exist. The executable /sbin/ping does.
So why when I'm running an interactive shell does typing a "bare" ping
work? Because the shell "environment" (defined for our purposes as "a
bunch of variables") includes a variable called PATH. The purpose of PATH
is to provide a list of directories to search for the command, when the
command is not given as a full path.
Start a shell window, and execute
ECHO $PATH
by hand.
You'll get something like (if you haven't installed the Developer Tools,
you'll probably get less):
[localhost:~] john% echo $PATH
/Users/john/bin/powerpc-apple-darwin:/Users/john/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
This is a : separated list (shell's text item delimiters is {":"}...sorry).
When looking for a command, the shell will look in each directory in the
list, in order. First hit wins (meaning you can arrange to use your own
ping command if you want to...here you could put it into /Users/john/bin to
do it the Mac OS X way).
Now let's see what sort of PATH variable is set up when I use do shell script:
do shell script "echo $PATH"
--> "/usr/bin:/bin:/Users/john"
No /sbin, therefore, no plain ping. That path is more inclusive than I'd
really like to see, for safety (there are too many easily wrongly spelt
command names).
</Podium mode>
--John
--
John Baxter email@hidden Port Ludlow, WA, USA
_______________________________________________
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.