linux - 如何在脚本中告诉如果 scp 失败,请尝试 wget

标签 linux

我有这个脚本:

cd /tmp/
scp user@8.8.4.1:/onboot/OTA.sh /tmp -i /usr/script/id 2> /dev/null
if
chmod 775 /tmp/OTA.sh
/tmp/OTA.sh &
sleep 30
rm -rf /tmp/OTA.sh

fi

我想在脚本中告诉如果 scp 失败,尝试 wget

最佳答案

man scp

EXIT STATUS
     The scp utility exits 0 on success, and >0 if an error occurs.

可以使用 bash 中的变量 $? 访问退出状态。

关于linux - 如何在脚本中告诉如果 scp 失败,请尝试 wget,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20514121/

相关文章:

Python - 如何从一行复制值,然后按原样粘贴到其他行值,或稍后修改它

linux - 旧的 Linux 内核奇怪的行为

linux - 我可以将我的应用程序代码放在我的 RAM 中的分区上吗?

linux - rsync 包含文件递归

c++ - io_getevents 在短于超时的时间内返回的作业数量少于请求的数量

linux - Echo 像书的索引一样排序

linux - Bash 变量管道在别名中不起作用?

linux - SysV 消息队列数量增加

android - 在开发 Android 应用程序时使用 Linux 操作系统重要吗?

linux - 高容量缓冲区 fifo 或使用文件作为 fifo 缓冲区