on OSX I do
sudo route delete default
sudo route add default 192.168.178.1
to change my default gateway.
On running a sh file with these I am asked for a password every time. Which I run as
sh changegw.sh
.
How do I pass my password before hand?
sudo sh changegw.sh
or runsudo bash
to get a root shell, then run your script from there. Then you won't need sudo in the script. – rob Mar 17 '12 at 21:51