Kindly help :::How can I send the output of the system() command to a file and capture a string i

P

prashant_ec2003

I am a newbie to perl.

How can I send the output of the system() command to a file and
capture a string in one of the lines in that file .

I will be thankful for your Suggestions and guidance

Thanks in Advance
prashant
 
J

Jürgen Exner

I am a newbie to perl.

How can I send the output of the system() command to a file and
[...]

Weren't you happy with the replies you got in the thread
"How can I send the output of the system() command to a file and capture a
string in that file"?

jue
 
P

prashant_ec2003

I want to use the system() command inside the open () and this is
where i am actualy finding the difficulty ..

i.e open ( FH, system ().. | ) ...

is there a way to do this ...

Thanks in Advance
Prashant
 
A

A. Sinan Unur

(e-mail address removed) wrote in @g49g2000cwa.googlegroups.com:
I want to use the system() command inside the open () and this is
where i am actualy finding the difficulty ..

i.e open ( FH, system ().. | ) ...

is there a way to do this ...

OK, off to the killfile you go.

*PLONK*
 
P

prashant_ec2003

actaully i want to pass the output of the system() command to the
open()..this is where i am facing the problem

i.e... open (FH, system() ...)

is there a way of doing this. ?

Thanks in Advance
prashant
 
T

Tad McClellan

I want to use the system() command inside the open ()


That isn't what you asked in either of your threads.

If you change the question, the answer is likely to change.

Many observers may choose to wait for the oscillations to damp to the
point where there is one target that isn't a moving target.

If you take more care in composing your question, you will get
much more rewarding responses than if you just spew out the
first thing that comes to mind.
 
L

lynn

Hello,

actaully i want to pass the output of the system() command to the
open()..this is where i am facing the problem
I think you are confused as to the purpose of the system command.
The system command runs the command and returns the exit status
whereas the backticks (``) runs the command and returns what it
sent to STDOUT.
What you want to do is run the command and grep for the line that you
want. Something like:
---------------
use strict;
use warnings;
my @out = grep {/^02/}`dir`;
^^^^^^^^^^^^^^^^^^^^^^^
print @out;

What this does is
run the dir command (capturing the output) feeding it to grep
where it will match any line that contains the string 02 at the beginning
of the line. This is put into the @out array.

I hope this helps.

Lynn
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top