Re: Shell and Perl scripts
Re: Shell and Perl scripts
- Subject: Re: Shell and Perl scripts
- From: Adam Wuellner <email@hidden>
- Date: Sat, 7 May 2005 01:09:05 -0500
On 5/7/05, Christopher Nebel <email@hidden> wrote:
> On May 6, 2005, at 9:45 PM, Paul FitzGerald wrote:
>
> > I can make the [shell] scripts work if I hard code some full paths
> > but I can't seem to find a way to make them work with default
> > paths. I have some test scripts (below) that demonstrate the
> > problem better than I can explain. If I run the shell script from a
> > terminal window I can make it work since it has a concept of a
> > current directory. But called from Automator it has issues.
> >
> > I start with a folder named "xxx" on my desktop and run the shell
> > script test.sh.
> > Both the shell script and the perl script are in a folder, also on
> > my desktop, named "process" along with the Automator workflow.
> >
> > test.sh
> > # This mv command works as expected, renaming the folder to the
> > name passed in as an argv.
> > mv ~/Desktop/xxx ~/Desktop/$1
> > # Calling the perl script as below does not work. It can't find the
> > perl script.
> > perl test.pl ~/Desktop/$1
> > # If I use a path to the perl script the script will run and
> > receive the argv as expected.
> > perl ~/Desktop/process/test.pl ~/Desktop/$1
> >
> > Thoughts? anyone?
>
> This is probably the same issue mentioned in TN2065 regarding the
> value of PATH. You can check the value by writing a two-action
> workflow: Run Shell Script (echo $PATH) > View Results. You'll
> probably find that /usr/bin isn't in it, which means you need to use
> the full path. (mv works because it's in /bin.)
But perl seems to work, and it's in /usr/bin. That is unless Paul's
test.pl starts with a valid #! line (in which case why invoke perl
like he is?)... I just tested the command 'perl -v' from Automator,
in the workflow you described. No problems.
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. I
wonder how he had it working in his previous AppleScript/shell/perl
workflow.
'echo $PATH' gives me '$PATH', btw. I had better luck with env(1):
temporary items
path=/Users/akw/Library/Caches/TemporaryItems/com.apple.Automator.DggcZj
path=
PWD=/
useInputAsArguments=0
commandOptions=1
SHLVL=0
COMMAND_STRING=env
Given that, why *can* it find, for example, mv and perl?
_______________________________________________
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