If you want to capture the return code from the other program then you need system.
Other methods for calling external programs (and another Perl program is just like any other external program) include backticks (aka qx//), fork/exec and open.
--
< http://dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] |
system('perl -e "exit 42"');
my $rc = $? >> 8;
print "return code=$rc\n";
For more details, see system et al, as suggested by davorg.
| [reply] [d/l] [select] |
| [reply] |
| [reply] |
Hi Smaug,
Thanks for the link. It is definitely good.
Cheers,
Bucchi
| [reply] |
I urgently need some help!!
Well quite about everybody here is likely to, but saying so doesn't generally help. Well, at least you didn't include the remark in the Subject, which is terribly annoying and likely to be eventually counter-productive.
I am trying to call a Perl script from another and capture the exit status (whether it was successful). How should I go about it? Please help....
Does the answer change if the thing were not necessarily a Perl script, but a generic program? No! Thus I recommend you to read perldoc -f system, which seems the most viable solution, in absence of further info.
Since the program to be called is a Perl script, there may actually be better strategies than plainly using system, but if you don't give further details, it's hard to say...
| [reply] |
In order to invoke inc.pl , I wrote,
system ("perl /u/niveditn/perl/myfolder/inc) ==0
or die "failed !" ;
But it showed compilation errors like :
Backslash found where operator expected at tmp line 1, near "rtf1\"
Backslash found where operator expected at tmp line 1, near "ansi\"
Backslash found where operator expected at tmp line 1, near "ansicpg1252\"
Backslash found where operator expected at tmp line 1, near "deff0\"
Backslash found where operator expected at tmp line 1, near "f0\"
Backslash found where operator expected at tmp line 1, near "froman\"
Backslash found where operator expected at tmp line 1, near "f1\"
Backslash found where operator expected at tmp line 1, near "fswiss\"
syntax error at tmp line 1, near "rtf1\"
syntax error at tmp line 1, near "f1\"
syntax error at tmp line 1, near "}}"
Can you please help?
| [reply] |
| [reply] |
Hey !!!
Thanks a ton!!! With notepad , I could finally call the other script!!
Thanks again for helping ,
Cheers
Bucchi
| [reply] |