So sometimes my Mac loses its connection to the Internet.
When I'm in front of it physically I can use the terminal and do the following to repair it:
networksetup -setnetworkserviceenabled ethernet off
type my password then:
networksetup -setnetworkserviceenabled ethernet on
and type my password again.
The thing is the machine is hosting several servers and I need them to be running even when I'm not physically present. So I wanted to run a daily script that would do this when I'm not present and be sure the connection is reset at least once a day. But since I haven't figured out a way to include my password in the command line I can't do that.
So my question is: is it possible to do what I described?
Best Answer
Ok, thank you Batman for suggesting to edit the sudoer file. Instead of crontab or launchd to schedule it once a day (which wasn't good enough anyway), I instead wrote that applescript to do it more regularly and so far it seems to be working:
I'm adding more details: I exported it as an .app then I edited the .plist of it with the lines:
To make it invisible when it runs (no dock icon) and finally I made it run on login.