[英]How to capture STDOUT from executable (cap) executed within a perl script executed from a crontab
Whew that is a long-winded title. 哇,这是一个漫长的标题。 But it explains my issue:
但这解释了我的问题:
I have a crontab that runs a perl script. 我有一个运行perl脚本的crontab。
That perl script runs a cap task, which outputs to STDOUT some status messages. 该perl脚本运行一个cap任务,该任务将一些状态消息输出到STDOUT。
The perl script is supposed to capture the STDOUT (currently using backticks) from cap and parse it. Perl脚本应该从cap捕获STDOUT(当前使用反引号)并进行解析。
Now, this works 100% fine when I run the script from a bash user. 现在,当我从bash用户运行脚本时,这可以100%正常工作。 However, when I run the script from a crontab, the perl script doesn't capture any output from the cap task.
但是,当我从crontab运行脚本时,perl脚本不会捕获cap任务的任何输出。
Has anyone dealt with anything like this before? 以前有没有人处理过类似的事情? Thanks.
谢谢。
Maybe your cap executables are died without emitting any message to stdout. 也许您的cap可执行文件已死,而没有向stdout发出任何消息。 Did you checking the success state of execution?
您是否检查了执行的成功状态?
Could you tried this? 你能试一下吗?
$check_result = `$cmd 2>&1`;
if ($?){
die "$cmd failed with $check_result, $!";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.