sachaer has asked for the wisdom of the Perl Monks concerning the following question:
I would like the execution output to be recorded in a text file: output.txt.
What I have done is in program2.pl:
Then add progam2.pl to cron job list. The next morning I will be able to read output.txt.$filename = "output.txt"; system("perl /absolute/path/to/program1> $filename");
What's in program1.pl:
Notice that I didn't define the output stream in program1.pl, so by default it goes to STDOUT.... print "Start xxx job..."; # some code to do the job print "End of doing xxx job.";
I have no problem finding the two print statements in my output file: output.txt. But when I do the following, I started getting problems:
What I want to do is perform a "cvs update" on a project's source code and then do something with the updated source code. I want to record the cvs update information, i.e. what file has been changed, what not, etc.. But if I do it in the way listed above, I sometimes get the CVS update in output.txt, most of the time I don't, although I am sure that source files are changed.(program1.pl) $projectSourceDir ='/absolute/path'; chdir $projectSourceDir; print "Do cvs update ...\n"; open INFO, "cvs update -dP |"; my @cvsInfo = <INFO>; close INFO; my $cvsInfo= join("", @cvsInfo); print "$cvsInfo"; print "done\n\n";
Thanks ahead.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: output to a file
by pzbagel (Chaplain) on Jun 19, 2003 at 19:15 UTC |