oleber
asked on
Get output from a program
I need the output of a program.
something like
$comandOutput = execute("ll");
print $comandOutput
that produce the some output that ll comand
something like
$comandOutput = execute("ll");
print $comandOutput
that produce the some output that ll comand
ASKER
perl -e 'my $a = qx[ll]; print $a;'
this didn't work for me. No output from the program
this didn't work for me. No output from the program
What is the program? Did you check $! for an error message?
my $output = qx[ll] or warn "couldn't run ll: $!";
print $output;
my $output = qx[ll] or warn "couldn't run ll: $!";
print $output;
does ll expect user input? probably replace by ls -la
ASKER
The problem is that I'm using a old version of Perl (5.005_03 for sun4-solaris), in windows with a newer version all solucitons works.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$output = `command`; # one big string
@output = `command`; # list of lines
$output = qx[command]; # one big string
@output = qw[command]; # list of lines
You can also use open(), but the above should be sufficient.