redss has asked for the wisdom of the Perl Monks concerning the following question:
If I have $FLUSH set to 1 and invoke it from a bash prompt, piping the output to "more", then I see a number displayed every second.#!/usr/bin/perl $FLUSH=1; while (1) { print "$i\n"; if ($FLUSH) { my($oldfh) = select(STDOUT); $| = 1; select($oldfh); } sleep 1; $i++; }
If I don't have $FLUSH set, then if I run it with the output piped to "more", I don't see any output.
Now say for example that FLUSH is NOT set and I am unable to set FLUSH (for example if I don't have permission to modify to the program).
If I want to run the command and pipe it to "more", is there a way for me to externally set STDOUT to "autoflush" when invoking the program?
(in specific my case, I need to access another compiled executable in C that does not flush output as it is written)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: can you autoflush a program in unix?
by ikegami (Patriarch) on Oct 20, 2009 at 18:47 UTC | |
by zwon (Abbot) on Oct 20, 2009 at 19:16 UTC | |
by ikegami (Patriarch) on Oct 20, 2009 at 19:33 UTC | |
by windowbreaker (Sexton) on Oct 20, 2009 at 19:02 UTC | |
by ikegami (Patriarch) on Oct 20, 2009 at 20:20 UTC | |
by Anonymous Monk on Oct 20, 2009 at 18:54 UTC | |
by ikegami (Patriarch) on Oct 20, 2009 at 20:21 UTC | |
by Anonymous Monk on Oct 21, 2009 at 14:56 UTC | |
|
Re: can you autoflush a program in unix?
by jakobi (Pilgrim) on Oct 20, 2009 at 20:28 UTC | |
|
Re: can you autoflush a program in unix?
by NiJo (Friar) on Oct 21, 2009 at 17:29 UTC |