I am under the impression (perhaps wrongly) that the ‘exec’ function in Perl does not return a value (I get the impression it just runs the command). The situation is that a Perl script is running on a server and I need to invoke this script to run commands inside the Linux box, but also return the results. How can this be done?
I am under the impression (perhaps wrongly) that the ‘exec’ function in Perl does
Share
If by “return the results” you mean return STDOUT of the commands, what you need is backticks or
qx(). E.g.:Do note that messages to STDERR are not returned.
If you mean the exit status of the program, use system: