Tuesday, October 16, 2012
10:00 PM

Perl Script: How to execute bash (or other) scripts from within the Perl script

system() executes the command specified. It doesn't capture the output of the command.

system() accepts as argument either a scalar or an array. If the argument is a scalar, system() uses a shell to execute the command ("/bin/sh -c command"); if the argument is an array it executes the command directly, considering the first element of the array as the command name and the remaining array elements as arguments to the command to be executed.

For that reason, it's highly recommended for efficiency and safety reasons (specially if you're running a cgi script) that you use an array to pass arguments to system().

Below is simple perl script which explains the concept of system() function call.
Continue Reading...

0 comments:

Post a Comment