如何调试 Perl CGI 脚本?

发布于 2024-08-12 05:36:30 字数 602 浏览 6 评论 0原文

我从旧服务器继承了一个旧的 Perl 脚本,该脚本正在被删除。该脚本需要在新服务器上执行。我已经在新服务器上了

脚本非常简单;它通过expect & 连接ssh 连接到网络设备并收集数据。出于调试目的,我仅使用从设备收集接口列表的部分。

新服务器上的脚本总是在重新加载后大约 5 秒内向我显示一个页面。它很少包含远程设备的接口列表。最常见的是,它包含除接口列表之外的所有 HTML 元素。

现在,在旧服务器上,有时脚本需要 20 秒才能输出数据。那很好。

基于此,新服务器上的 apache 似乎在 Perl 脚本完成返回其数据之前显示数据,尽管这肯定是不正确的。

其他信息: 不幸的是,我无法发布任何代码 - 工作政策。不过,我很确定这不是expect的问题。期望部分被写为expect()或die('error msg'),我没有看到错误消息。但是,如果我将预期超时设置为 0,那么我确实会看到错误消息。

脚本中使用的expect超时值通常是20秒...但是正如我上面提到的,apache在大约5秒后显示脚本中的静态内容,并且95%的时间不显示应该从expect检索的内容。此外,该脚本会将预期内容写入驱动器上的文件中 - 即使页面未显示该内容。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

走野 2024-08-19 05:36:30

我刚刚将我的Perl CGI 脚本故障排除指南添加到 Stackoverflow。 :)

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

紫竹語嫣☆ 2024-08-19 05:36:30

您可以尝试 CGI::Inspect。我不需要亲自尝试,但我看到它在 YAPC 上演示,并且它看起来棒极了。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文