Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print to a file

Status
Not open for further replies.

sswanstr

Technical User
Apr 28, 2008
5
US
I have a perl script that works great and prints the output to the console screen. However, if I try to redirect the output on the command line, nothing gets printed to the file. I tried modifying the script to print to a file instead of the screen but get the same results (nothing in the output file). Any suggestions as to what might be going on?
 
permissions isn't the issue. Before attempting to write to the file I touch it and chmod it to 777:

system("touch image_report.out");
system("chmod 777 image_report.out");
open (OUTFILE, '>>image_report.out');
 
I am running the script as root on the server so there is no issue with permissions.

That being said I let the script run to completion this time and it looks like it dumps all the output to the file at the same time once the script completes. Though when I run it normally it prints stuff to the screen in bursts.
 
With no code, the question is a little vague, hence the short answer.

Do you have strict and warnings set in your code ?
Are you checking to see if the file is opened successfully? ( open "image_report.out" or die ? )

That you can't redirect STDOUT to the intended file from the command line seems to be the real issue.
It says to me that the file cannot be created/appended to, hence permissions (or quotas).
Either that or the script is producing no output to STDOUT.
 
Is the output that you are seeing on the screen stuff you are printing.. or stuff coming from STDERR from system calls?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
based on the code you have provide above, you need to show if this is inside a loop -- to clarify "bursts of data on screen".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top