#!/bin/bash
input=""
echo "Does a wall needs to be sent?"
read input
if [ "$input" = "yes" ]; then
echo "Sending message to all user about a system reboot or shutdown"|wall
elif [ "$input" = "no" ]; then
exit
fi
echo "Is this a reboot or shutdown?"
read input
if [ "$input" = "reboot" ]; then
echo "System is rebooting"
shutdown -r +1
elif [ "$input" = "shutdown" ]; then
echo "System is about to shutdown"
shutdown -h +1
fi
echo "Goodbye"
我想弄清楚的是,如果我不发送墙,那么我想得到提示语句 echo“这是重新启动还是关闭?”
当我不想发送墙时,我该怎么做而不是让脚本退出
答案1
删除两行:
elif [ "$input" = "no" ]; then
exit
你应该表现得很好。