0

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.

Svante
  • 50,694
  • 11
  • 78
  • 122
nfarrar
  • 2,291
  • 4
  • 25
  • 33
  • 6
    Unfortunately I left my crystal ball at home, but I would imagine the Expect script is waiting for some predefined timeout instead of matching output. Please post some code. – Leonardo Herrera Nov 18 '09 at 17:44
  • 1
    There's really too many variables to really give an exact answer here. It could be anything from a difference in buffer flushing, to a different version of perl/expect, or even user permissions in relation to access to the network devices, etc. – Dustin Hansen Nov 18 '09 at 17:55
  • 1
    I wouldn't guess that this is an apache problem. Most likely it merely shows the data that the script gives it. What happens when you run the script on the command line? – brian d foy Nov 18 '09 at 19:23
  • 2
    You're going to have to isolate the problem a bit further; maybe post a sanitized version of some code at that point. – Paul Nathan Nov 18 '09 at 20:30
  • See also [How can I troubleshoot my Perl CGI script?](http://stackoverflow.com/questions/2165022/how-can-i-troubleshoot-my-perl-cgi-script) – Ether Jul 02 '10 at 22:00

2 Answers2

3

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

Community
  • 1
  • 1
brian d foy
  • 129,424
  • 31
  • 207
  • 592
1

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

cjm
  • 61,471
  • 9
  • 126
  • 175