DiGregorio, Dave am Dienstag, 7. März 2006 19.30:
> Ok, I am trying to run another perl script from a perl script and have
> had little luck in doing so. The main script is in one directory and
> the one it is controlling is in another directory. the main script
> starts and calls the other script which is supposed to read a file.
> However,
> I get can not find the "readfile" which is located in the same
> directory as the script called by the first.
I don't unterstand this part about "readfile" completely; do you call it from
someScript.pl? And how?
> Now, if I run the called
> script by itself the problem goes away and all is good. So the problem
> I believe is caused by the CWD of the commanding script. To get around
> this I tried:
>
You already got hints about the backslash in perl. Although, I would rewrite
the code as follows:
> chdir("C:\Go\Here\") || die "cant not change dir\n" ;
chdir ('C:\Go\Here\') or die 'cant not change dir\n';
- No double qoutes needed because no variables are interpolated into strings
- 'or' has lower precedence than '||'
> system("perl someScript.pl -a createOperator -p f112a") || die "$_";
system('perl someScript.pl -a createOperator -p f112a') == 0
or die "'system' failed: $?";
The same holds here about the double quotes (wich should be avoided in system
calls anyway).
But the line has another two problems:
First, $? (not $_) contains the exit status of system.
Second, success in the shell is indicated by a return value of 0, which is
true in the shell, but false in perl. So, this codeline dies always if system
succeeded and never if it didn't.
I tried my above lines under linux, and everything was ok.
hth,
Hans
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>