perl script output can't be redirected to a file
The perl script I wrote works fine if I print the result to screen
x0_amber.pl 1 1000 0 5 But whenever I want to output to a file with x0_amber.pl 1 1000 0 5 > x0_out it never really prints out to the file. It worked earlier, but I was playing with my PATH lately, I don't know if it's related to that |
Quote:
|
Quote:
frame 1-1000 0 1 0.1 1 0.2 1 0.3 0.98 0.4 0.97 0.5 0.96 .... The first line "frame 1-1000" should be printed out before any calculation is done. |
Quote:
#!/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) { for($i=$frame1;$i<=$frame2;$i++) { open(PDB,"$traj.$i"); @line_pdb=<PDB>; close PDB; } $x0=$n_count/$no_frm; print "$r $x0\n"; } If I comment out the content in the inner loop, it prints out to a file ok. However if I uncomment these three lines, it just can't print to a file. |
When you run an executable file in BASH, the process of redirection is normally (I'm pretty sure) independent of what is inside the executable file. The exception I suppose is if the executable does something that overrides the re-direction.
If it does not output to a file, where DOES the output go? |
Quote:
|
1. use the following
Code:
#!/usr/bin/perl -w Code:
for($i=$frame1;$i<=$frame2;$i++) 3. This var is not defined/set anywhere: $n_count : so the calc & print will not do what you want. |
Quote:
|
All times are GMT -5. The time now is 03:37 AM. |