perl解释器的状态码是什么意思?

发布于 2024-08-25 02:04:58 字数 250 浏览 3 评论 0原文

我正在尝试使用 Java 的 Runtime.exec() 执行 Perl 解释器的副本。但是,它返回错误代码 9。运行该文件几次后,perl 解释器神秘地开始返回代码 253,而我的命令根本没有任何变化。

代码 253 / 代码 9 是什么意思?在 Google 上搜索 perl 解释器的退出代码没有找到任何结果。在哪里可以找到 Perl 解释器的退出代码列表?

I'm trying to execute a copy of the Perl interpreter using Java's Runtime.exec(). However, it returned error code 9. After running the file a few times, the perl interpreter mysteriously started to return code 253 with no changes in my command at all.

What does code 253 / code 9 mean? A Google search for perl interpreter's exit codes turned up nothing. Where can I find a list of exit codes for the Perl interpreter?

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

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

发布评论

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

评论(5

执妄 2024-09-01 02:04:58

请参阅 perldoc perlrun

如果程序语法正确,则执行该程序。如果程序运行结束时没有命中 exit()die() 运算符,则会提供隐式 exit(0) 来指示成功完成。

因此,您正在运行的程序必须以某种方式通过 die, < a href="http://perldoc.perl.org/functions/exit.html" rel="nofollow noreferrer">exit 或同等内容。

See perldoc perlrun:

If the program is syntactically correct, it is executed. If the program runs off the end without hitting an exit() or die() operator, an implicit exit(0) is provided to indicate successful completion.

Thus, the program you are running must be somehow specifying those exit values via die, exit or equivalent.

北座城市 2024-09-01 02:04:58

如果脚本不运行,perl 解释器实际上确实返回它自己的退出代码。大多数语法错误会导致退出代码 9:

未知函数/不允许的裸字:

perl -e 'use strict; print scalar(localtime); schei;'

$? = 9

除以零:

perl -e 'use strict; print scalar(localtime); my $s = 1/0;'

$? = 9

语法错误:

perl -e 'use strict; print scalar(localtime); my $ff; $ff(5;'

$? = 9

使用 die:

perl -e 'use strict; print scalar(localtime); die "twaeng!"'

$? = 9

未知模块是我发现 perl 以不同方式退出的唯一一种情况:

perl -e 'use strict; use doof; print scalar(localtime);'

$? = 2

顺便说一句,我仍在寻找 Perl 解释器退出代码的完整列表。除了 Perl 解释器源之外,有人知道去哪里看吗?

The perl interpreter actually does return exit codes of its own if the script doesn't run. Most syntax errors lead to exit code 9:

Unknown function / disallowed bareword:

perl -e 'use strict; print scalar(localtime); schei;'

$? = 9

division by zero:

perl -e 'use strict; print scalar(localtime); my $s = 1/0;'

$? = 9

syntax error:

perl -e 'use strict; print scalar(localtime); my $ff; $ff(5;'

$? = 9

using die:

perl -e 'use strict; print scalar(localtime); die "twaeng!"'

$? = 9

an unknown module was the only one situation I found perl to exit differently:

perl -e 'use strict; use doof; print scalar(localtime);'

$? = 2

BTW I'm still searching for a comprehensive list of the perl interpreter's exit codes myself. Anyone got an idea where to look, aside from the perl interpreters sources?

苍暮颜 2024-09-01 02:04:58

在正常情况下,perl 将返回它运行的程序返回的任何内容。因此,在不知道它正在运行的程序的情况下,您无法概括返回值的含义。

In normal circumstances, perl will return whatever the program it runs returns. Hence you can not generalize the meaning of the return value without knowing the program it's running.

吲‖鸣 2024-09-01 02:04:58

Perl 本身没有任何定义的退出代码;除非 perl 解释器以非常可怕的方式崩溃,否则退出代码由 perl 正在运行的程序决定,而不是由 perl 本身决定。

Perl itself doesn't have any defined exit codes; unless the perl interpreter crashes in a really horrific way, the exit code is determined by the program that perl is running, not by perl itself.

千秋岁 2024-09-01 02:04:58

由于运行几次后错误代码发生了变化;如果您将 Java 应用程序作为持续运行的 Web 应用程序运行,请检查是否存在某种内存泄漏。

您可以通过使用 perl 解释器的 -Tw 选项运行您的 perl 脚本来测试其是否存在各种问题,有关启用的污染模式和警告,请参阅 perlrun 有关这些的更多信息。

Since the error code changed after some runs; if you are running a Java app as a continuously running webapp, check if it can be some kind of memory leak.

You can test your perl script from various problems by running it with the perl interpreter's -Tw options, for tainted modes and warnings enabled, see perlrun for more info about these.

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