English 中文(简体)
How can I debug a Perl CGI script?
原标题:

I inherited a legacy Perl script from an old server which is being removed. The script needs to be implemented on a new server. I ve got it on the new server.

The script is pretty simple; it connects via expect & ssh to network devices and gathers data. For debugging purposes, I m only working with the portion that gathers a list of the interfaces from the device.

The script on the new server always shows me a page within about 5 seconds of reloading it. Rarely, it includes the list of interfaces from the remote device. Most commonly, it contains all the HTML elements except the list of interfaces.

Now, on the old server, sometimes the script would take 20 seconds to output the data. That was fine.

Based on this, it seems that apache on the new server is displaying the data before the Perl script has finished returning its data, though that could certainly be incorrect.

Additional Information: Unfortunately I cannot post any code - work policy. However, I m pretty sure it s not a problem with expect. The expect portions are written as expect() or die( error msg ) and I do not see the error messages. However, if I set the expect timeout to 0, then I do see the error messages.

The expect timeout value used in the script normally is 20 seconds ... but as I mentioned above, apache displays the static content from the script after about 5 seconds, and 95% of the time does not display the content that should retrieved from expect. Additionally, the script writes the expect content to a file on the drive - even when the page does not display it.

问题回答

I just added my Troubleshooting Perl CGI scripts guide to Stackoverflow. :)

You might try CGI::Inspect. I haven t needed to try it myself, but I saw it demonstrated at YAPC, and it looked awesome.





相关问题
Why does my chdir to a filehandle not work in Perl?

When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "...

How do I use GetOptions to get the default argument?

I ve read the doc for GetOptions but I can t seem to find what I need... (maybe I am blind) What I want to do is to parse command line like this myperlscript.pl -mode [sth] [inputfile] I can use ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签