O
olson_ord
Hi,
I want to call/run another program with a perl script - and I need
to look at the current output on the screen and at the same time I need
this output dumped to a file. Without using perl I would just use tee.
However within perl it seems that its having some problem with the pipe
symbol "|".
As an example I have subsituted ls for my actual program and its
arguments (it has many of these). My script looks something like
--------------------------------------------
#!/usr/bin/perl
use strict; use warnings;
my @args = ("ls", "|", "tee", "out.txt");
print "\n\nExecuting @args \n";
system (@args) == 0 or die "System @args failed: $? \n";
---------------------------------------------------------------------
The output that I receive from the command line is something like
Executing ls | tee out.txt
ls: |: No such file or directory
ls: tee: No such file or directory
out.txt
System ls | tee out.txt failed: 256
I know that tee and | are not arguments to ls. However if I execute
this using back ticks then I don't get the output on the screen - so
thats not an option.
Thanks a lot for taking your time to help me.
O.O.
I want to call/run another program with a perl script - and I need
to look at the current output on the screen and at the same time I need
this output dumped to a file. Without using perl I would just use tee.
However within perl it seems that its having some problem with the pipe
symbol "|".
As an example I have subsituted ls for my actual program and its
arguments (it has many of these). My script looks something like
--------------------------------------------
#!/usr/bin/perl
use strict; use warnings;
my @args = ("ls", "|", "tee", "out.txt");
print "\n\nExecuting @args \n";
system (@args) == 0 or die "System @args failed: $? \n";
---------------------------------------------------------------------
The output that I receive from the command line is something like
Executing ls | tee out.txt
ls: |: No such file or directory
ls: tee: No such file or directory
out.txt
System ls | tee out.txt failed: 256
I know that tee and | are not arguments to ls. However if I execute
this using back ticks then I don't get the output on the screen - so
thats not an option.
Thanks a lot for taking your time to help me.
O.O.