Output of a perl script to a file 
Author Message
 Output of a perl script to a file

I execute the following line in ms-dos in the directory the script is found:

perl -we "if ($| = open STDERR,q{>warnings.txt}) { do (q{script.cgi}); }"
### "do"

The above line will produce an warnings.txt file when errors are reported in
the script when run from the prompt.  Good way to debug.

What am trying to accomplish is to place the what returns on screen after a
script is executed into a file.

For example I may have a script that will return stocks when run, those
market stock i like to place in a text file.



Tue, 20 Dec 2005 22:45:22 GMT  
 Output of a perl script to a file

Quote:

> I execute the following line in ms-dos in the directory the script is found:

> perl -we "if ($| = open STDERR,q{>warnings.txt}) { do (q{script.cgi}); }"
> ### "do"

> The above line will produce an warnings.txt file when errors are reported in
> the script when run from the prompt.  Good way to debug.

> What am trying to accomplish is to place the what returns on screen after a
> script is executed into a file.

Why can you not simply use the same trick for STDOUT?

This newsgroup does not exist (see FAQ).  Please do not start threads here.



Wed, 21 Dec 2005 01:23:48 GMT  
 Output of a perl script to a file
Simplest method it just piping the output to a file:

perl file.pl > output.txt

... all text on the console goes into output.txt.

or do it within the script:

# > overwrites, >> appends
open (OUT, ">output.txt") | die "couldn't open file";
print OUT "text that goes in the output.txt file";
print "text that only goes to console";

-Ken


Quote:
> I execute the following line in ms-dos in the directory the script is
found:

> perl -we "if ($| = open STDERR,q{>warnings.txt}) { do (q{script.cgi}); }"
> ### "do"

> The above line will produce an warnings.txt file when errors are reported
in
> the script when run from the prompt.  Good way to debug.

> What am trying to accomplish is to place the what returns on screen after
a
> script is executed into a file.

> For example I may have a script that will return stocks when run, those
> market stock i like to place in a text file.



Fri, 23 Dec 2005 13:18:58 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. redirecting output from one perl script to a file (withough changing the perl script itself)

2. Re-direct the error (!) output of a perl script to a file from within the perl script

3. error opening a pdf file output from perl script

4. Perl script to combine GIFS to file or output

5. output a binary file to browser from perl script

6. Incomplete output from crontab email: running shell scripts from a perl script

7. changing the output file for every script run

8. Getting Leading Space in Script Output File---HELP

9. Embedded script & output files

10. Advice on script: problem opening file for output

11. script outputting file instead of html page

12. script output to a file

 

 
Powered by phpBB® Forum Software