Quote:
Originally Posted by Bone11409
Hey I just try your script here on my laptop and it did not work for me. Also could you walk me threw that command I have not seen it before.
command substitution: line 6: syntax error near unexpected token `newline'
/Users/bone/Desktop/fixodtest: command substitution: line 6: ` '10.184.16.1' '
/Users/bone/Desktop/fixodtest: line 6: syntax error near unexpected token `;;'
/Users/bone/Desktop/fixodtest: line 6: ` ;;'
|
The GNU Bash Reference Manual and
Advanced Bash-Scripting Guide describe the case-esac command.
As a matter of good practice I changed the double quotes around the IP addresses to single quotes (it would have worked with the double quotes but it is prudent to use single quotes unless double quotes are necessary).
I changed $1floor to ${1}floor presuming you wanted the value of $1 suffixed with the string 'floor' -- the original usage would have referenced a variable named 1floor.
Regards your error, try changing
Code:
gateway=$(netstat -r | grep default | awk '{print $2}'
to
Code:
gateway="$(netstat -r | grep default | awk '{print $2})')"
Sorry -- I did not notice the missing ')' in your original post. Adding the double quotes is good practice in case the string returned by the netstat command has embedded whitespace; without the double quotes bash would try to run anything after the whitespace as a command.