test.pl cant be modified, im looking for something that will work with any program, my own or not.
On Sep 9, 10:11 pm, [EMAIL PROTECTED] (Raymond Wan) wrote: > Hi, > > Seems like what you need is to do an "autoflush". Try searching for it > with Google...this might be a good start and enough for what you want: > > http://bytes.com/forum/thread603712.html > > Note that stdout tends to be buffered and stderr not (since it's for > error messages and they should appear "right away"). So, you may not > need to do this with stderr. > > There was another way to flush output, which I forgot...but I think if > you search for "flush" or "autoflush", you'll come across it... > > Ray > > doubleHelix wrote: > > I am having a problem in capturing the output and exit value from a > > system command that prompts the user for input. The following shows a > > simplification of the problem. Im trying to get it so that all the > > text before the prompt gets output before the script gets stuck at the > > prompt. I’m sure it is possible, but my knowledge of ttys and file > > reads and writes is failing me now. > > > test.pl > > ===== > > # the less I can assume about test.pl the better. > > # It shouldn’t matter if the prompt is on STDOUT or STDERR, I want to > > capture all of it. > > > print "Hello World!\n"; > > print "Enter something: "; > > chomp ($foo = <STDIN>); > > print "Thanks for inputting that $foo\n"; > > > wraptest.pl > > ======== > > > $| = 1; > > print "in wraptest\n"; > > open CMD, "perl test.pl 2>&1 |" or die "couldnt fork: $!"; > > while ( <CMD> ) { > > print "hi $_"; > > } > > close CMD; > > print "exit value: ", $?>>8, "\n"; > > > output > > ===== > > > in wraptest > > <PROMPT> > > hi Hello World! > > hi Enter something: Thanks for inputting that $PROMPT > > exit value: 0 > > > I’d like to modify wraptest.pl so that the output would be > > > in wraptest > > hi Hello World! > > hi Enter something: <PROMPT> > > hi Thanks for inputting that $PROMPT > > exit value: 0 > > > Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/