ikuzmanovs has asked for the wisdom of the Perl Monks concerning the following question:
I have read about several ways of calling a shell command from within a perl script (system command, backticks, exec..)I tried them on a very simple program but they do not really work as I want to.
I have a program "success.pl" which only prints "Success" on the screen and another program called "program.pl" from within which I try to execute the program success.pl. I tried the following:
@var=`success.pl`; print @var;
Nothing is printed on the screen :(
2.system
I get -1@var=system("success.pl") or die "cant run"; print @var;
3.open
I get: Undefined subroutine &main::OPEN called at program.pl line 3 :(OPEN(FH, "success.pl"); @var=<FH>; close(FH); print $var;
4.exec
I get 0@var=exec ("success.pl") or die "cant run"; print @var;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Running perl script from a perl script
by afoken (Chancellor) on Jan 08, 2010 at 16:46 UTC | |
Re: Running perl script from a perl script
by kennethk (Abbot) on Jan 08, 2010 at 16:44 UTC | |
Re: Running perl script from a perl script
by zentara (Cardinal) on Jan 08, 2010 at 17:02 UTC | |
Re: Running perl script from a perl script
by jettero (Monsignor) on Jan 08, 2010 at 16:37 UTC | |
Re: Running perl script from a perl script
by jffry (Hermit) on Jan 08, 2010 at 17:58 UTC | |
Re: Running perl scrit from a perl script
by ww (Archbishop) on Jan 08, 2010 at 21:50 UTC |