检查 wget 的返回值 [英] Check wget's return value
本文介绍了检查 wget 的返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个脚本来下载一堆文件,我希望它在某个特定文件不存在时发出通知.
I'm writing a script to download a bunch of files, and I want it to inform when a particular file doesn't exist.
r=`wget -q www.someurl.com`
if [ $r -ne 0 ]
then echo "Not there"
else echo "OK"
fi
但它在执行时出现以下错误:
But it gives the following error on execution:
./file: line 2: [: -ne: 期望的一元运算符
怎么了?
推荐答案
$r
是 wget 的文本输出(您用反引号捕获了它).要访问返回代码,请使用 $?
变量.
$r
is the text output of wget (which you've captured with backticks). To access the return code, use the $?
variable.
这篇关于检查 wget 的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文