Re: 'do shell script'-bug?
Re: 'do shell script'-bug?
- Subject: Re: 'do shell script'-bug?
- From: Christopher Nebel <email@hidden>
- Date: Fri, 11 Jan 2002 23:09:18 -0800
On Friday, January 11, 2002, at 07:31 PM, christian vick wrote:
If i use...
tell application "Terminal"
do script with command "echo password | sudo bless -folder9
\"/Volumes/9disk/System Folder 922\" -setOF"
end tell
... it works. But if i use...
do shell script "echo password | sudo bless -folder9
\"/Volumes/9disk/System
Folder 922\" -setOF"
... i get an error "sudo: bless: command not found".
Is this a bug or am i missing something?
This is not a bug, but it's also not well documented.
When you tell Terminal to do something, it does it using your preferred
shell (tcsh, unless you've changed it) and complete login environment.
When you use "do shell script", it always uses sh, and some environment
bits are different. In particular, PATH is not the same, so not all
commands can be found automatically. (Try "echo $PATH" both ways to see
what I mean.) Use the full path to the command (/usr/sbin/bless in this
case) and you should be fine.
I'm not sure what you're doing with the "echo password | sudo", though.
I presume you're trying to supply the sudo password via echo, but you'll
need to say "sudo -S" for that to work. Even easier would be to use the
optional "with administrator privileges" and "password" parameters.
--Chris Nebel
AppleScript Engineering