获取shell脚本里面从PHP脚本退出状态 [英] Retrieve exit status from php script inside of shell script

查看:708
本文介绍了获取shell脚本里面从PHP脚本退出状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个调用一些PHP脚本这样一个bash shell脚本。

I have a bash shell script that calls a few PHP scripts like this.

#!/bin/bash

php -f somescript.php

php -f anotherscript.php

我要编写基于这些脚本的结果,错误日志和/或活动报告。

I want to compose an error log and/or an activity report based on the results of those scripts.

有什么办法,我可以得到的PHP脚本中的shell脚本的退出状态?

Is there any way I can get the exit status of the php script in the shell script?

我既可以使用整数退出状态或字符串的邮件。

I could either use integer exit statuses or string messages.

推荐答案

您可以轻松地使用的反引号的操作器锁扣的输出,并获得在最后一个命令的退出code 使用的 $ 的:

You can easily catch the output using the backtick operator, and get the exit code of the last command by using $?:

#!/bin/bash
output=`php -f somescript.php`
exitcode=$?

anotheroutput=`php -f anotherscript.php`
anotherexitcode=$?

这篇关于获取shell脚本里面从PHP脚本退出状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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