Chinaunix
标题:
shell脚本中如何判断umount的成功/失败
[打印本页]
作者:
wooin
时间:
2014-03-15 10:37
标题:
shell脚本中如何判断umount的成功/失败
shell脚本中应该如何表达这个意思呢?
if [ umount /mnt/disk ]; then
echo "umount done!"
fi
谢谢!
作者:
ly5066113
时间:
2014-03-15 11:14
回复
1#
wooin
umount /mnt/disk && echo "umount done!"
复制代码
或者:
umount /mnt/disk
if [ $? -eq 0 ]; then
echo "umount done!"
fi
复制代码
作者:
waker
时间:
2014-03-15 11:35
if umount /mnt/disk
then
echo "umount done!"
fi
umount /mnt/disk&&echo "umount done!"
作者:
haokoo
时间:
2014-03-15 13:30
本帖最后由 haokoo 于 2014-03-15 13:33 编辑
回复
3#
waker
umount 执行成功不是应该返回0嘛? 那if的判断应该不会执行吧?
测试了一下,判断通过...为毛
作者:
waker
时间:
2014-03-15 15:10
回复
4#
haokoo
PAGER='less -iRsp "exit status"' man bash
作者:
liyunxiang12
时间:
2014-03-15 18:46
回复
4#
haokoo
shell中 0 也是true
作者:
haokoo
时间:
2014-03-18 14:56
回复
5#
waker
if list; then list; [ elif list; then list; ] ... [ else list; ] fi
The if list is executed. If its exit status is zero, the then list is executed. Other-
wise, each elif list is executed in turn, and if its exit status is zero, the corresponding
then list is executed and the command completes. Otherwise, the else list is executed, if
present. The exit status is the exit status of the last command executed, or zero if no
condition tested true.
复制代码
看到了,谢谢提醒。
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2