您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 为什么执行 shell 返回值为 1?

2024/2/22 8:06:54发布21次查看
能成功执行,但是打印的数值是1,按道理来说正常不是1吗?只有错误才会别的
回复内容:
能成功执行,但是打印的数值是1,按道理来说正常不是1吗?只有错误才会别的
我们看下官方文档的说法:
成功则返回命令输出的最后一行, 失败则返回 false
再看看英语版:
returns the last line of the command output on success, and false on failure.
实际上,这两种说法都容易引起歧义,正确的理解应该是
成功则返回命令的退出码

exit(code)
中的code。
大部分情况下,exit(0)代表没有错误。然而这并不代表所有。
具体的需要在对应命令下man wget
以下是结果:
exit status wget may return one of several error codes if it encounters problems. 0 no problems occurred. 1 generic error code. 2 parse error---for instance, when parsing command-line options, the .wgetrc or .netrc... 3 file i/o error. 4 network failure. 5 ssl verification failure. 6 username/password authentication failure. 7 protocol errors. 8 server issued an error response. with the exceptions of 0 and 1, the lower-numbered exit codes take precedence over higher-numbered ones, when multiple types of errors are encountered.
所以等于0确实是代表成功,而等于1代表了出错。
你的文件真的下载成功了吗?
-1到底啥意思呢?
500m的文件?超时了吧
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product