当 Perl 连接远程主机失败时,如何让 Perl 回退到只执行而不调试?
[root@ test]$ PERLDB_OPTS=RemotePort=localhost:1111 perl -d typeglob
Unable to connect to remote host: localhost:1111
Compilation failed in require.
at typeglob line 0
main::BEGIN() called at /usr/lib/perl5/5.8.8/perl5db.pl line 0
eval {...} called at /usr/lib/perl5/5.8.8/perl5db.pl line 0
BEGIN failed--compilation aborted.
at typeglob line 0
正如您所看到的,当连接失败时,程序就会失败并退出。我怎样才能让它运行,就像这种情况中未指定-d
一样?
[root@ test]$ PERLDB_OPTS=RemotePort=localhost:1111 perl -d typeglob
Unable to connect to remote host: localhost:1111
Compilation failed in require.
at typeglob line 0
main::BEGIN() called at /usr/lib/perl5/5.8.8/perl5db.pl line 0
eval {...} called at /usr/lib/perl5/5.8.8/perl5db.pl line 0
BEGIN failed--compilation aborted.
at typeglob line 0
As you see,when it fails to connect,the programe just fails and exits.How can I make it just run as if -d
is not specified in that case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不明白你想在这里执行的任务。不确定为什么要在这里调用 perl 调试器?但我想知道该 CLI 命令是否有返回代码?
如果是这样,也许您可以编写一个 shell 脚本来以第一种方式执行 perl,如果它返回失败代码,只需将 CLI 更改为不使用 -d 开关即可执行。
所以,换句话说,可能有一种 perl 方法可以做你想做的事,但剥猫皮的方法有很多......
I don't understand the task you are trying to perform here. Not sure why you're invoking the perl debugger here? But I'm wondering if there's a return code from that CLI command?
If so, maybe you can write a shell script to execute perl the first way and if it returns a failure code, just change the CLI to execute without the -d switch.
So, in other words, there may be a perl way to do what you want but there are many ways to skin a cat...