Executing commands.

C

Connell Gauld

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
 
P

Paul Lalli

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top