Capturing Command Line Output 
Author Message
 Capturing Command Line Output

I'm in the process of writing a script that will read in my current
dynamic ip address for update in my apache server's httpd.conf file.
However, I'm at a lose as how to capture output from a command line
response.

I've tried using the 'system' command but can't figure out how to
capture STDOUT using it.  I was trying to use 'qx//' but again I am at a
lose when trying to capture the STDOUT.

Any suggestions on how to capture STDOUT from the command line without
me having to type it in manually?



Sun, 22 Oct 2000 03:00:00 GMT  
 Capturing Command Line Output


Quote:
>I've tried using the 'system' command but can't figure out how to
>capture STDOUT using it.  I was trying to use 'qx//' but again I am at a
>lose when trying to capture the STDOUT.

perhaps if you showed a snippet we could point out the mistakes. :)

Quote:
>Any suggestions on how to capture STDOUT from the command line without
>me having to type it in manually?

have you seen perlfaq8 and perlipc?

good luck :)

--

CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>



Sun, 22 Oct 2000 03:00:00 GMT  
 Capturing Command Line Output



Quote:
> However, I'm at a lose as how to capture output from a command line
> response.

  This rings a bell... and backticks is the reply I get. I see that you've
tried to use qx// - the slightly more meta'ed version of ``. Here is what
I'd use to fetch the output from for instance nslookup:

    my($lookup) = join('', `nslookup hostname`) ;

  which leaves me with a string - $lookup - containing the STDOUT from the
process nslookup.

  Was this what you were looking for ?

  (Caveat: I've not taken into account the path to the program here, nor any
           error messages in $!, etc, etc, etc. Such things are left as an
           exercise for the reader :)

--
  Tina Marie Holmboe                

  Scandinavia Online AB Development Dept.    (+46) 08 587 81000 (switchboard)
                                             (+46) 08 587 81189 (direct)



Mon, 23 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. capturing command-line output in NT - grrr!

2. capturing command line error or output from `<command>`

3. Output of a command line command

4. capturing output of FILEHANDLE "| command"

5. capturing output from a remote command (how?)

6. Capturing System Command Output with Perl on Windows/Apache

7. capturing output of executed system command

8. capturing output of piped commands

9. Help with Piped command, capturing output

10. Capture command output into list?

11. Capturing output of a system command

12. help with capturing output of open command

 

 
Powered by phpBB® Forum Software