my perl script has parts that look like this:
print "==== doing something 1 ====
";
system(myprog bla);
print "==== doing something 2 ====
";
system(myprog bla2);
If I run the script in the shell, I get the correct output order -something like:
==== doing something 1 ====
myprog is running for bla
==== doing something 2 ====
myprog is running for bla2
BUT if I redirect the output (using myscript.pl > tmp.out) then the output is not in the correct order:
myprog is running for bla
myprog is running for bla2
==== doing something 1 ====
==== doing something 2 ====
What is the cause for this and how do I fix it?
thnx
Keren
Comments
:
: print "==== doing something 1 ====
";
: system(myprog bla);
: print "==== doing something 2 ====
";
: system(myprog bla2);
:
: If I run the script in the shell, I get the correct output order -something like:
:
: ==== doing something 1 ====
: myprog is running for bla
: ==== doing something 2 ====
: myprog is running for bla2
:
: BUT if I redirect the output (using myscript.pl > tmp.out) then the output is not in the correct order:
:
: myprog is running for bla
: myprog is running for bla2
: ==== doing something 1 ====
: ==== doing something 2 ====
:
: What is the cause for this and how do I fix it?
:
: thnx
: Keren
:
:
Odd....I've never tried outputting to a file that way. Why is this neccessary?
-----------------------
"The three principle virtues of a programmer are laziness, impatience, and hubris"
I wonder, could it be something to do with buffers not flushing properly or something? I think there is something you can do in Perl to change when a the buffer flushes or there may be a flush function/sub/command that you could call. I can't remember either, but if you or someone can dredge those up, it may be worth a try.
Jonathan
-------------------------------------------
Count your downloads:
http://www.downloadcounter.com/
And host your site:
http://www.incrahost.com/
Don't say I never give you anything... ;-)
In short, I can't imagine working without it.
K
: : my perl script has parts that look like this:
: :
: : print "==== doing something 1 ====
";
: : system(myprog bla);
: : print "==== doing something 2 ====
";
: : system(myprog bla2);
: :
: : If I run the script in the shell, I get the correct output order -something like:
: :
: : ==== doing something 1 ====
: : myprog is running for bla
: : ==== doing something 2 ====
: : myprog is running for bla2
: :
: : BUT if I redirect the output (using myscript.pl > tmp.out) then the output is not in the correct order:
: :
: : myprog is running for bla
: : myprog is running for bla2
: : ==== doing something 1 ====
: : ==== doing something 2 ====
: :
: : What is the cause for this and how do I fix it?
: :
: : thnx
: : Keren
: :
: :
: Odd....I've never tried outputting to a file that way. Why is this neccessary?
: -----------------------
: "The three principle virtues of a programmer are laziness, impatience, and hubris"
:
: