检查的wget的返回值[IF]

编程入门 行业动态 更新时间:2024-10-22 23:46:48
本文介绍了检查的wget的返回值[IF]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在写一个脚本下载一堆文件,我想它通知当一个特定的文件不存在。

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` if [ $r -ne 0 ] then echo "Not there" else echo "OK" fi

但它给上执行了以下错误:

But it gives the following error on execution:

./文件:第2行:[:-ne:一元运算符预期

怎么了?

推荐答案

$ R 是wget的文本输出(你已经与反引号捕获)。要访问返回code,使用 $?变量。

$r is the text output of wget (which you've captured with backticks). To access the return code, use the $? variable.

更多推荐

检查的wget的返回值[IF]

本文发布于:2023-10-28 18:13:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537388.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:返回值   wget

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!