Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Executing commands. (http://www.velocityreviews.com/forums/t885637-executing-commands.html)

Connell Gauld 03-05-2004 09:21 PM

Executing commands.
 
Hey,
I'm trying to right a perl script on Linux which will run a certain
executable.
Is there a Perl command which will do this eg:
command "/bin/something parameters";

Thanks for any help.
Connell Gauld



Paul Lalli 03-05-2004 09:34 PM

Re: Executing commands.
 
On Fri, 5 Mar 2004, Connell Gauld wrote:

> Hey,
> I'm trying to right a perl script on Linux which will run a certain
> executable.
> Is there a Perl command which will do this eg:
> command "/bin/something parameters";
>
> Thanks for any help.
> Connell Gauld


There are several.

$s = system ("/bin/something parameters"); will call whatever shell you're
using, and return the exit code of 'something'.

$s = system ("/bin/something", "parameter1", "paremeter2"); will call
'something' directly, bypassing the shell, and feeding it the paremeters.
Again returns the exit code.

$s = `/bin/something parameters`; returns the output of the command.

@s = `/bin/something parameters`; returns the output of the command as an
array, with each element containing one line of output.


Then there are pipes, which are mildly more complicated. If you just want
to run an external program, chances are you don't need them.

Paul Lalli


All times are GMT. The time now is 09:13 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.