I have a perl script which calls another script. I am calling it using backticks and passing argument to that script and it works fine.
`CQPerl call_script.p
If you wan't to do error checking, backticks may be a wrong approach. You probably want to use the system
function. See the documentation for all the details of error handling, examples included.
Perl has a number of possibilites to execute other scripts / commands:
qx{}
When you want to read all the output at once after the program has terminatedexec
When you wan't to continue your process as another program — never returns if succesfullsystem
When you are only interested in the success or failure of the commandopen
When you want to pipe information to or from the commanddo
and require
Execute another Perl script here. Similar to C's #include
open
so that you have access to STDIN
, STDOUT
and STDERR
of the program you executed. See the apropriate parts of perlipc for advanced information.And always use the multi-argument forms of these calls to avoid shell escaping (can be annoying and very insecure).
Check the value of the perl special variable $?
to determine if there was an error.