
oscarjiao
Novice
Feb 18, 2010, 1:23 PM
Post #1 of 5
(452 views)
|
|
Why is it not printing instantly
|
Can't Post
|
|
This script handles a large number of file, and prints out some result for each of them.
#!/usr/bin/perl if ($#ARGV != 5) { die "Usage x0_amber traj_name frame1 frame2 r0 r1 dr\n"; } $traj=$ARGV[0]; $frame1=$ARGV[1]; $frame2=$ARGV[2]; $r0=$ARGV[3]; $r1=$ARGV[4]; $dr=$ARGV[5]; print "frame $frame1-$frame2\n"; $no_frm=$frame2-$frame1+1; for($r=$r0;$r<=$r1;$r=$r+$dr) { foreach $i($frame1..$frame2) { open(PDB,"$traj.$i"); @line_pdb=<PDB>; close PDB; for ($j=0;$j<=$#line_pdb;$j++) { #calculation skipping print ..... } } $x0=$n_count/$no_frm; print "$r $x0\n"; } If I ask it to write to the screen, it prints out right away. But if I redirect the output to a file: x0_amber.pl tra.pdb 1001 10000 1 5 0.1 > x0_out & it doesn't print out until the program reaches the end and prints out everything at once. When I do "grep WAT * > wat.log", the wat.log gets updated immediately. Why can't my script print out to a file instantaneously?
|