bash-2.05a$ sh
sh-2.05a$ echo $path
$path:/usr/local/bin
sh-2.05a$ echo $PATH
/bin:/sbin:/usr/bin:/usr/sbin:/Library/Tcl/bin:/usr/local/bin
I get that and in AppleScript:
do shell script “echo $path”
→ “$path:/usr/local/bin”
do shell script “echo $PATH”
“/usr/bin:/bin:/usr/sbin:/sbin:/Users/kel”
You see hos the $PATH is different with sh. Is AppleScript running a different sh shell? I tried looking on the internet for the sequence of configuration files for sh, but just could find that it starts with the /etc/profile config file.
I don’t have a very good understanding of this, but from what I’ve heard, the default shell that terminal runs is bash (and the default for the system), while AppleScript prefers to run sh.
Doing.
echo $SHELL
.and.
do shell script "echo $SHELL"
.returns ‘/bin/bash’ for both, but doing.
echo $BASH
.and.
do shell script "echo $BASH"
.returns ‘/bin/bash’ from the Terminal, and ‘/bin/sh’ from AppleScript.
Yeah, I don’t think do shell script uses sh. I think it’s using bash even though it’s returning /bin/sh. The reason why I say this is because I configured it to use ~/.profile to set the environment variable ENV to us a file ~/.shinit which sets the PATH variable, but the shell is not even looking at the ~/.profile config file.
I’m attempting to set the PATH the bash way for the do shell script.
I tried the ~/.MacOSX/environment.plist before and deleted it thinking it didn’t work. But, I didn’t logout of the system and back in. Later on, I hd changed the default shell with NetInfo Manager and the changes didn’t take place until I logged out. After changing the default shell and running a ‘do shell scirpt’:
do shell script “echo $SHELL”
the result would be the old defualt shell. So, I did know that things were set in the ‘do shell script’ at login to the system, but didn’t know that the environment.plist file pertained to logging in. I’m still wondering where the ‘do shell script’ command is getting its information without the environment.plist file existing.
If anyone wants to know to add the plist.
First see if ~/.MacOSX/environment.plist exists. If not create the path to it. In Terminal I used ls, mkdir, and pico. Added to the plist this: