Motley has asked for the wisdom of the Perl Monks concerning the following question:
Ok, I'm a programmer that has been given the task to fix a bug with a Perl-generated web page. I have a background in mainframe programming, and I don't know a thing about Perl so please be gentle.
The page that I'm having trouble with is a query page that greps a particular log file for the a series of strings {tty2, tty3, tty4, ...., tty17} for a given date range.
The code is a loop from 2 - 17 that runs this grep:
$start_ts = sprintf("\"%s %s:%s:00\"",$fromdate,$hr,$min); $end_ts = sprintf("\"%s %s:%s:00\"",$todate,$tohour,$tomin); for ($i = $TTYFIRST; $i <= $TTYLAST; $i++) { Tty_check($i,$start_ts,$end_ts,$selectedserver); } sub Tty_check { $tty_string = sprintf( "tty%d", $_[0] ); $tty = qx{aml_read /l trace /h $_[3] /a commproc /s $_[1] /b $_[2] + /d all | egrep -c -e $tty_string}; printf("<TR ALIGN=LEFT VALIGN=TOP>\n"); printf("<TD>%s</TD>\n",$tty_string); chomp($tty); printf("<TD>%d</TD>\n",$tty); printf("</TR>\n"); }
The query should return a number count for each string search. I've run the line from a UNIX prompt with hardcoded information in the variable names and received correct results. But through the Perl script the program falsely returns 0 as the count or ends abnormally before it can dynamically create the web page (I get a page not found error). Hardcoding the variable information in the Perl script and running it also works. The variables are also displayed and they appear to be correct.
I guess I have 2 questions:
1. Any suggestions on how to debug this?
2. I was hoping to display what that actual query looks like within the qx .... is there
a way to write that out to a file or the html page?
Thank you for any help.
Bryan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: a dumb question
by swiftone (Curate) on Dec 05, 2000 at 01:04 UTC | |
|
Re: a dumb question
by swiftone (Curate) on Dec 05, 2000 at 01:35 UTC | |
by Motley (Initiate) on Dec 05, 2000 at 02:43 UTC | |
by runrig (Abbot) on Dec 05, 2000 at 03:46 UTC | |
by Motley (Initiate) on Dec 05, 2000 at 03:00 UTC | |
|
Re: a dumb question
by runrig (Abbot) on Dec 05, 2000 at 01:30 UTC |