Re: Shell and Perl scripts
Re: Shell and Perl scripts
- Subject: Re: Shell and Perl scripts
- From: Dave Gillam <email@hidden>
- Date: Sat, 7 May 2005 07:26:12 -0500
From the manpage for bash:
When bash is started non-interactively, to run a shell
script, for
example, it looks for the variable BASH_ENV in the
environment, expands
its value if it appears there, and uses the expanded value
as the name
of a file to read and execute. Bash behaves as if the
following com-
mand were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the PATH variable is not used to search
for the file
name.
The stock /etc/profile (which is read by bash when invoked (ie: a
shell script is run) is:
# System-wide .profile for sh(1)
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
export PATH
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
So try duplicating the PATH assignment for BASH_ENV, thus:
# System-wide .profile for sh(1)
PATH="/bin:/sbin:/usr/bin:/usr/sbin"
export PATH
BASH_ENV="/bin:/sbin:/usr/bin:/usr/sbin"
export BASH_ENV
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
This *should* give the script-invoked bash the path you are seeking.
Dave Gillam
email@hidden
On May 7, 2005, at 1:15 AM, Steve Hayman wrote:
On 7-May-05, at 2:09 AM, Adam Wuellner wrote:
I think the problem is the working directory - Paul's test.sh is run
from /, inherits no PATH from its environment (other than /), and so
when it calls test.pl it can't be located without the full path.
Yup, that's it. Try putting "pwd" in for your script followed by a
"View Results", and it'll print the working directory, which is
"/". Apps launched from the finder, including Automator, generally
run with their current directory set to "/".
Given (no PATH environment variable), why *can* it find, for
example, mv and perl?
It's running bash to execute the script, and if bash sees an empty
PATH environment variable, it defaults to something like "/bin:/usr/
bin". So you get a reasonable PATH even if one isn't found in the
environment.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Automator-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Automator-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden