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

Discussion in 'Perl Misc' started by prashant_ec2003@yahoo.com, Jun 19, 2005.

  1. Guest

    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
     
    , Jun 19, 2005
    #1
    1. Advertising

  2. wrote in news:1119210049.983382.75910
    @g49g2000cwa.googlegroups.com:

    > I am a newbie to perl.


    It seems like you are newbie to UseNet as well. Please read

    <URL:http://groups-beta.google.com/support/bin/answer.py?answer=12348
    &topic=250>

    to learn how to participate in UseNet discussions.

    Posting the exact same request several times is considered rude and
    unacceptable.

    Sinan

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Jun 19, 2005
    #2
    1. Advertising

  3. wrote:
    > 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
     
    Jürgen Exner, Jun 19, 2005
    #3
  4. Guest

    Re: Kindly help :::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 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
     
    , Jun 19, 2005
    #4
  5. Re: Kindly help :::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

    wrote in news:1119213291.288530.149520
    @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*

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Jun 19, 2005
    #5
  6. Guest

    Re: Kindly help :::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

    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
     
    , Jun 19, 2005
    #6
  7. Re: Kindly help :::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

    <> wrote:

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


    > is there a way to do this ...



    No.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jun 20, 2005
    #7
  8. Re: Kindly help :::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

    <> wrote:

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


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jun 20, 2005
    #8
  9. lynn Guest

    Re: Kindly help :::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

    Hello,

    wrote:
    > 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
     
    lynn, Jun 21, 2005
    #9
    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. Navin
    Replies:
    3
    Views:
    668
    Navin
    Jul 28, 2003
  2. muralidharan

    Null Exception error - Kindly help me

    muralidharan, Aug 10, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    566
    muralidharan
    Aug 10, 2004
  3. Ernesto
    Replies:
    1
    Views:
    795
    Ernesto
    Feb 1, 2006
  4. Siddhu
    Replies:
    11
    Views:
    564
    osmium
    Jun 6, 2007
  5. Replies:
    5
    Views:
    169
    Big and Blue
    Jun 20, 2005
Loading...

Share This Page