Re: Very basic question on reading error messages
by broquaint (Abbot) on Sep 07, 2001 at 21:37 UTC
|
Perhaps not a basic solution to a basic questions, but hopefully useful all the same
$SIG{__WARN__} = sub {
open(ERR, ">>error.log") or die ("Died because: $!\n");
print ERR @_;
close(ERR);
};
What this does is re-assigns the __WARN__ signal handler (the thing that handles all warnings) to an anonymous sub that outputs the warnings to a file. So now STDERR should be nice and quiet.
HTH
broquaint | [reply] [d/l] [select] |
Re: Very basic question on reading error messages
by runrig (Abbot) on Sep 07, 2001 at 21:17 UTC
|
Redirect errors to a file and read them at your leisure: perl myprogram.pl 2>errors.txt
# Or on WinNT you can do just like Unix:
perl myprogram.pl 2>&1 | more
| [reply] [d/l] |
|
The first one doesn't work under Win9x either (IIRC). If you are on Win9x, the command shell is so broken that there is no way to get it to send STDERR to a file. Luckilly, you have Perl which means you have lots of ways you could do it:
perl -e "open(STDERR,'>>errors.log'); do 'script.pl'"
perl -e "open(STDERR,'>>errors.log'); exec $^X,'script.pl'"
to give just a couple that I didn't notice already in this thread. (:
-
tye
(but my friends call me "Tye") | [reply] [d/l] |
|
program -args >& out.txt
works just fine if you use the 4NT shell. Nobody in his right mind who actually uses the command line would try and cope with CMD.exe or worse yet COMMAND.COM.
—John
| [reply] [d/l] |
Re: Very basic question on reading error messages
by demerphq (Chancellor) on Sep 07, 2001 at 22:31 UTC
|
Aside from the other worthy responses about how to capture to a file or to use more you could get yourself an editor that will do it for you.
My preference is UltraEdit (I am a W2K user), but there are many others (and for as many editors there are there are 100 times more opinions as to which is the best etc, the source of many a holy flame war). I suggest you do a search for programming editors in super search.
Another advantage to using a propper editor is that you get syntax highlighting, hexadecimal view, commenting in some even auto-format. A good programming editor is just as useful (if not more) than an IDE like VB/C++ and is an essential part of a good coders toolbox.
Yves
--
You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM) | [reply] |
Re: Very basic question on reading error messages
by jlongino (Parson) on Sep 07, 2001 at 21:21 UTC
|
If you don't want to mess with a separate file, use:
perl myprogram.pl | more
Update: Sorry. The above doesn't work as per
blakem (below). Could have sworn I used it before. BTW,
it doesn't work for similar reasons under Unix either.
@a=split??,'just lose the ego and get involved!';
for(split??,'afqtw{|~'){print $a[ord($_)-97]} | [reply] [d/l] |
|
That will pipe STDOUT through more, but if
a ton of messages are being dumped to STDERR it wont solve
anything. Use something like this to send both STDERR and STDOUT through more
perl myprogram.pl 2>&1 | more
-Blake
| [reply] [d/l] [select] |
|
Under 4NT shell, myprogram |& more or better yet myprogram |& list /S.
—John
| [reply] [d/l] [select] |
Re: Very basic question on reading error messages
by cmilfo (Hermit) on Sep 07, 2001 at 22:53 UTC
|
If you are new to Perl (I think you mentioned this earlier), then you might be new to the whole command line programming scene. If you don't like writing your output to a file and reading, you might try just making your command prompt buffer bigger. It has been a while since I've changed this, but if memory serves me, you right click on the menu bar of your window and click on properties. Then look through the menu options for the buffer size. Crank that puppy up!
Another option for you might be to use an IDE. Then your output will be written to an onscreen scrollable buffer.
I've seen two that look decent:
Komodo from ActiveState
PerlBuilder from SolutionSoft
They both cost money, but sometimes it is worth it. Personally, I just use Vim. But, I work on Linux machines, and I can make my command line buffers, HUGE.
Cheers! | [reply] |
|
... and because it is perl, we have also free open-source IDE:
Jürgen Güntherodt anounced Open Perl IDE, free lookalike of VisualPerl, with features:
-Perl Syntax Coloring
-Visual Debugging
-Integrated Help System
-Customizable Environment
Jürgen invited to look at http://open-perl-ide.sourceforge.net
Try take a look, and then tell us...:)
pmas
To make errors is human. But to make million errors per second, you need a computer.
| [reply] |
Re: Very basic question on reading error messages
by jerrygarciuh (Curate) on Sep 07, 2001 at 23:50 UTC
|
Thank you all for answers!
I am working on using them now.
º º º (or peas by degrees)
jg | [reply] |