标签:roo bin echo $? shell命令 命令 exe exec exiting this
vi no_interaction_script1.sh
#!/bin/bash
#提示用户该脚本3秒后退出
echo "This script will quit after 3 seconds. "
#计时3s
sleep 1
echo -n "."
sleep 1
echo -n "."
sleep 1
echo "."
./no_interaction_script1.sh
This script will quit after 3 seconds.
...
vi root_or_not.sh
#!/bin/bash
#设置退出状态为5
exitcode=5
#设置退出时的提示
message="Sorry, you are not root.. exiting"
#判断当前用户是否是root
if [ $UID -ne 0 ]
then
echo "$message" >&2
exit $exitcode
fi
#如是查root用户, 将执行下面的脚本内容
echo "If the user is root, will execute this now. "
#script_end
./root_or_not.sh
Sorry, you are not root.. exiting
echo $?
5
标签:roo bin echo $? shell命令 命令 exe exec exiting this
原文地址:https://www.cnblogs.com/zhudaheng123/p/14649471.html