Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: reading output from another script

by Abigail-II (Bishop)
on Jul 23, 2003 at 14:35 UTC ( #277168=note: print w/replies, xml ) Need Help??


in reply to reading output from another script

open my $pipe => "tail -f /syslog.log" or die "Fork failed: $!"; while (<$pipe>) { ... whatever ... }

But beaware of pipe buffers.

Abigail

Replies are listed 'Best First'.
Re: Re: reading output from another script
by zby (Vicar) on Jul 23, 2003 at 14:40 UTC
    This assumes the stream would be line oriented. Of course that should be true for most circumstances (he even mentions tail -f). But if it is not things get a bit more tricky and he would need to read character by character by some low level system call.
      Well, yeah, and things could even be more tricky if the read in characters are in some strange encoding, and an obscure language. ;-)

      I read the article from the OP as if (s)he had problems with the fact that the source (s)he's reading from continues to produce data - not that (s)he needed help with non line oriented input. But even if you want to read byte by byte, just do a S/ = \1 before reading.

      Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://277168]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2022-01-16 18:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (49 votes). Check out past polls.

    Notices?