从bash脚本获取perl脚本的输出并退出

use*_*986 2 bash perl

从bash脚本如何执行perl脚本获取输出并在值为0时退出?另外在perl脚本中我如何返回值,我只是返回它还是打印它?

Wil*_*ell 5

#!/bin/bash

perl-script args && exit

如果你想继续运行,返回值是$?

请注意,perl脚本返回的值与脚本的输出之间存在区别.要获取脚本的输出,请使用$()运算符:

#!/bin/bash
output=$(perl-script args)

echo The perl script returned $?
echo The output of the script was $output