echo "Select your option:"
echo "1. Change ip address"
echo "2. Add route"
echo "3. Reboot"
echo "4. Exit"
read A
case $A in
1)
echo "Add Ip address"
read IP
echo "Add Netmask"
read Netid
echo "Add name of interface"
read Interface
ifconfig ${Interface} ${IP}/${Netid}
if [ $? -ne 0 ];then
echo "Ip address not configured"
fi
;;
2)
echo "Add Destination"
read dst
echo "Add Netmask"
read Netid
echo "Add Gateway"
read gw
route add $dst mask $Netid gw $gw
if [ $? -ne 0 ];then
echo "Route not added"
fi
;;
3)
reboot
;;
4)
echo "Bye"
exit 0
;;
default)
echo "Wrong selection"
exit 1
esac
错误:
[b104@b104 Downloads]$ ./NetworkUtility.sh
./NetworkUtility.sh: line 1: $'\r': command not found
Select your option:
1. Change ip address
2. Add route
3. Reboot
4. Exit
1
': not a valid identifier 7: read: `A
./NetworkUtility.sh: line 8: $'\r': command not found
./NetworkUtility.sh: line 9: syntax error near unexpected token `newline'
'/NetworkUtility.sh: line 9: `case $A in
[b104@b104 Downloads]$