Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: watch-script.pl | less +F buffering problem?

by axelrose (Scribe)
on Aug 18, 2006 at 14:13 UTC ( #568158=note: print w/replies, xml ) Need Help??


in reply to Re: watch-script.pl | less +F buffering problem?
in thread watch-script.pl | less +F buffering problem?

Hi liverpole,

thanks for your reply.

I thought about the input buffers of less as well but was surprised to see that perl -e 'print "a line\n" x 10' | less +F works.

Another workaround is to send the output of my watch script to another file and oberserving this with "less +F".

My intention is to browse back the output over several pages and do occasional searches. I couldn't normally implement this myself.

Axel.

Replies are listed 'Best First'.
Re^3: watch-script.pl | less +F buffering problem?
by liverpole (Monsignor) on Aug 18, 2006 at 14:30 UTC
    That's because, in the case of:
    perl -e 'print "a line\n" x 10' | less +F
    the end-of-file is encountered as soon as the program finishes, so the pipe gets the end-of-file, and less knows it has received all the input it's going to get.

    Here's a good way to test it -- try executing the following command:

    perl -e 'while (1) {print "a line\n" x 1000; sleep 1}' | less

    Now the input buffer to less will fill up almost immediately, so you'll see the output right away.  However, if you execute the command "G", it will never find the end-of-file, because the end-of-file hasn't been written yet!

    Similarly if you execute the same command with less +G at the end instead of less, you'll never see output for the same reason.


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2020-04-06 03:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (36 votes). Check out past polls.

    Notices?