Then save your changes and run your script. See if that worked. Did it give you your expected output?print STDERR "Well, I made it to line: ", __LINE__, ".\n";
If not, debug that. If so, uncomment a small block of code and copy your debug statement just below it. Run your test again.
Feel free to comment out debug statements earlier in the script, if they have told you what they need to. But don't delete them, As your script matures, they may get reworked as log statements and be used again.
As you copy your debug line down past tested and working code, you can make the debug output more informative, say by writing it this way:
Have you examined the logfile you are processing? Does it contain any lines matched by your regex? If you run this file without redirecting its output, do you see any feedback in the console?print STDERR "At line: ", __LINE__, ", the message type is $2, so we'l +l append to the log.\n"; etc. . . .
You would likely learn quite a bit about your script were you to write conditions to handle exceptions. Robust code includes lots of conditional paths that the programmer expects will never be taken by legitimate data in a production environment. But coding that exception handling will help you see where you perhaps made bad assumptions about what your code is actually doing. A properly handled exception might recover so the script need not terminate. It could add useful debugging information to a log file. At the very least it could die in a loud and descriptive way.
-- Hugh
In reply to Re: Empty output file with Red Hat
by hesco
in thread Empty output file with Red Hat
by vineet2004
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |