Re: [PBML] Re: how to redirect output
- On Mon, 04 Dec 2000 13:06:43 -0000,
>> >This won't work for me, because i'm running the perl interpreterYou might want to post the line you're using to spawn the
>> >a Visual Basic program (with the Shell command). Your suggestion
>> >works when i run the script from the DOS-box. (I'm working on a NT
>> >machine.) The solution i'm looking for should be independant from
>> >DOS-box, so probably within the script itself.
>> There still shouldn't be any reason you can't pass the
>> redirection to the shell command. Simply add the ">
>> mytextfile" to the command which spawns the shell.
>No, it doesn't work...
shell. You may having something wrong with your specific
>> If that won't work for some reason, how it the output withinSTDOUT is where normal text is printed. It's usually the
>> the script being created? Are you creating it, or is it an
>> error message or similar from perl itself? If you're
>> creating it via print statements or some such, you can
>> simply print to a file. If it's automatically generated,
>> you need to redirect stdout and/or stderr to the file. If
>> you can't figure out how to do that from your docs, repost
>> and I'll include an example.
>Actually it's both. I'm getting strings back from functions and print
>them. But Perl also automatically creates messages that i want to
>write to the file. How do i redirect these stout and/or stderr? It
>would be very nice if you could provide me with such an example!
monitor screen, but doesn't necessarily have to be.
STDERR is where error messages are printed. It's usually
the same place as STDOUT but doesn't have to be.
open (STDOUT, ">C:\\OUTFILE.LOG");
open (STDERR, ">C:\\ERROR.LOG");
print "This is a test.";
#prints string to OUTFILE.LOG
open (BAD_FILE, "NON_EXISTENT.FIL") or die "Can't open
#prints error message to ERROR.LOG
You can, of course, send normal output and error output to
the same file if you wish.