从 shell 脚本调用 Perl,如何将 Perl 的返回值传递给 shell? [英] Calling Perl from a shell script, how do I pass a return value from Perl to the shell?

查看:110
本文介绍了从 shell 脚本调用 Perl,如何将 Perl 的返回值传递给 shell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功地从 shell 脚本调用了 Perl 脚本.现在我想将 Perl 脚本的返回值传递给 shell 脚本,指示它是否成功.我该怎么做?

I'm successfully calling a Perl script from a shell script. Now I want to pass a return value from the Perl script indicating whether it was successful or not to the shell script. How would I go about doing this?

推荐答案

只需使用适当的退出值退出 Perl 脚本.

Simply exit the Perl script with the appropriate exit value.

exit $exit_value;

exit 0;

if ($problem) { exit 1 }

在 shell 脚本中,您将使用通常的 $? 来检查返回值.

In the shell script you'll have the usual $? to check the return value.

这篇关于从 shell 脚本调用 Perl,如何将 Perl 的返回值传递给 shell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆