shell - '\r': command not found -


echo "select option:" echo "1. change ip address" echo "2. add route" echo "3. reboot" echo "4. exit" read 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 

error:

[b104@b104 downloads]$ ./networkutility.sh  ./networkutility.sh: line 1: $'\r': command not found select option: 1. change ip address 2. add route 3. reboot 4. exit 1 ': not 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]$  

it seems have windows style line endings (\r\n) - need change them unix style (\n). if have dos2unix installed use it. using sed or awk.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -