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
오류 :' R': 명령을 찾을 수 없습니다
[[email protected] 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
[[email protected] Downloads]$
스크립트 파일은 DOS/윈도우 스타일의 라인 엔딩 ('\ r에 \의 n')를 포함,이 쉘을 혼란 것입니다. 유닉스 라인 엔딩 ('\ n')으로 저장하십시오. –
'tr -d "\ r" cleaned.sh'를 실행하고'./cleaned.sh'가 더 잘 작동하는지 확인할 수 있습니다. –
이 질문에 대한 가장 불행한 점은 얼마나 오래 되었습니까? 두 줄짜리 줄 바꿈 (한 줄짜리와 한 줄짜리 빈 줄이있는 경우)이 정확히 20 줄짜리 스크립트를 만들지는 않을 것입니다. 같은 문제. –