out put from system()

E

ecnalbya

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;
 
M

Mirco Wahab

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.
 
G

Gunnar Hjalmarsson

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
 

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,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top