in reply to Re^3: Filtering passwords from the output of a script
in thread Filtering passwords from the output of a script

Caveat: What if "hide" and "_me" are received seperatly?

That, together with the requirement for the stream to be as unbuffered as possible, is why it would be wrong to use "4096" (or any value greater than "1") on the sysread call.

  • Comment on Re^4: Filtering passwords from the output of a script

Replies are listed 'Best First'.
Re^5: Filtering passwords from the output of a script
by ikegami (Patriarch) on Nov 29, 2006 at 05:43 UTC
    Not so. Unlike read (which waits for all 4096 characters to be read in) and <FILE> (which waits for a whole line to be read in), sysread returns as soon as possible. For example,
    perl -e "$|=1; print 'test1'; sleep 1; print 'test2'" | perl -e "sysre +ad(STDIN, $buf='', 1000); print(qq{[$buf]})"

    outputs

    [test1]

    If what you claimed is true, it would output [test1test2].

    ( And I'm working on the caveat. And I've addressed the caveat in an update. )