Executing commands.

Discussion in 'Perl Misc' started by Connell Gauld, Mar 5, 2004.

  1. 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
    Connell Gauld, Mar 5, 2004
    #1
    1. Advertising

  2. Connell Gauld

    Paul Lalli Guest

    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
    Paul Lalli, Mar 5, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mitchley
    Replies:
    0
    Views:
    606
    Mitchley
    Jun 10, 2004
  2. FyinsFlip
    Replies:
    4
    Views:
    3,465
    bruce barker
    Dec 29, 2004
  3. Daniel Portal

    Executing DOS commands from ASP.NET

    Daniel Portal, Nov 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,632
    Lau Lei Cheong
    Nov 19, 2005
  4. Ben Pfaff

    Re: man pages for C commands (GCC commands)

    Ben Pfaff, Jun 24, 2003, in forum: C Programming
    Replies:
    4
    Views:
    3,947
    Thomas Stegen
    Jun 28, 2003
  5. Tim Stanka
    Replies:
    1
    Views:
    785
    Jeff Epler
    Aug 2, 2004
Loading...

Share This Page