写一个脚本用wget发送一个http 到一个网站,如果通过会下载一个文件,如果没有通过返回403,sleep 120s 重新发送 如果返回204 ,退出脚本
请问怎么实现啊,怎么判断这个返回值
谢谢啊
请教一个问题啊
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
- 木头人
- 帖子: 479
- 注册时间: 2011-07-17 9:33
Re: 请教一个问题啊
ee大神能不能详细点啊eexpress 写了:--tries=
--timeout=
都有啊。
shell判断成功,可以后句写 $?
[ $? -eq 0 ] && xxxxxx;
我要写一个脚本放在cron中 定期发送http请求下载
由于是在openwrt上,只能使用wget发http了
我想把发送的过程写成一个函数,
if xxx
then
elif
xxx
我怎么能调用这个返回值,作为判断的条件
@eexpress
- astolia
- 论坛版主
- 帖子: 6703
- 注册时间: 2008-09-18 13:11
Re: 请教一个问题啊
他的意思是你不用自己去判断成没成功,直接用wget的参数就够了
--waitretry 可以设置重试等待时间
--tries 可以设置重试次数
你非要自己去判断的话去检查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.
In versions of Wget prior to 1.12, Wget's exit status tended to be
unhelpful and inconsistent. Recursive downloads would virtually always
return 0 (success), regardless of any issues encountered, and non-
recursive fetches only returned the status corresponding to the most
recently-attempted download.
--waitretry 可以设置重试等待时间
--tries 可以设置重试次数
你非要自己去判断的话去检查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.
In versions of Wget prior to 1.12, Wget's exit status tended to be
unhelpful and inconsistent. Recursive downloads would virtually always
return 0 (success), regardless of any issues encountered, and non-
recursive fetches only returned the status corresponding to the most
recently-attempted download.
-
- 帖子: 51
- 注册时间: 2006-12-29 20:45
Re: 请教一个问题啊
$? 就是上一条命令的返回值...