How can I check the status of the first program in pipeline in Perl's system()?

后端 未结 7 548
小蘑菇
小蘑菇 2021-01-21 06:41
perl -e \'system (\"crontab1 -l\");print $?\'

returns -1 as expected (program crontab1 doesn\'t exist)

perl -e \'system (\"crontab1 -l|         


        
7条回答
  •  面向向阳花
    2021-01-21 07:27

    The operating system returns an exit status only for the last program executed and if the OS doesn't return it, perl can't report it.

    I don't know of any way to get at the exit code returned by earlier programs in a pipeline other than by running each individually and using temporary files instead of pipes.

提交回复
热议问题