out put from system()

Discussion in 'Perl Misc' started by ecnalbya@gmail.com, Aug 4, 2007.

  1. Guest

    Are there any ways to get system output from Perl? I want to get out
    put from system() and print it out in Perl. For example,


    #! /use/bin/perl
    $output = system ("echo hello world");
    print $output;
    , Aug 4, 2007
    #1
    1. Advertising

  2. Mirco Wahab Guest

    wrote:
    > Are there any ways to get system output from Perl? I want to get out
    > put from system() and print it out in Perl. For example,
    >
    >
    > #! /use/bin/perl
    > $output = system ("echo hello world");
    > print $output;



    either use back ticks `echo "hello world!"`
    or the qx operator ...

    # without any interpolation of variables or expressions
    ...
    $output = qx'echo "hello world!"';
    print $output;
    ...

    # interpolation of variables or expressions
    ...
    $text = "hello world!";
    $output = qx{echo $text};
    print $output;
    ...

    see http://perldoc.perl.org/perlop.html#`STRING`

    Regards

    M.
    Mirco Wahab, Aug 4, 2007
    #2
    1. Advertising

  3. wrote:
    > Are there any ways to get system output from Perl? I want to get out
    > put from system() and print it out in Perl. For example,
    >
    > #! /use/bin/perl
    > $output = system ("echo hello world");
    > print $output;


    You asked a FAQ.

    perldoc -q output.+system

    Btw, did you consider to read the docs for the function you thought you
    want to use?

    perldoc -f system

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Aug 4, 2007
    #3
    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. Steve
    Replies:
    0
    Views:
    5,316
    Steve
    Jul 1, 2003
  2. Rhino
    Replies:
    0
    Views:
    1,632
    Rhino
    Nov 13, 2004
  3. JGH
    Replies:
    2
    Views:
    6,926
    Malte
    Feb 23, 2005
  4. ash
    Replies:
    1
    Views:
    1,724
    Janusch
    Mar 25, 2008
  5. Gabriel Rossetti
    Replies:
    3
    Views:
    533
    Jerry Hill
    Apr 25, 2008
Loading...

Share This Page