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.

5
  • 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. Commented Nov 18, 2009 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. Commented Nov 18, 2009 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? Commented Nov 18, 2009 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. Commented Nov 18, 2009 at 20:30
  • See also How can I troubleshoot my Perl CGI script? Commented Jul 2, 2010 at 22:00

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.