Terminal asking for password

When I"m in front of it physically I deserve to use the terminal and also perform the adhering to to repair it:

networksetup -setnetworkserviceenabled ethernet offkind my password then:

networksetup -setnetworkserviceenabled ethernet onand type my password again.

You watching: Terminal asking for password

The point is the machine is hosting several servers and I require them to be running even once I"m not physically existing. So I wanted to run a everyday manuscript that would certainly perform this as soon as I"m not present and also be certain the connection is recollection at least as soon as a day. But because I haven"t figured out a means to encompass my password in the command also line I can"t execute that.

So my question is: is it feasible to carry out what I described?


terminal mac password
Share
Improve this question
Follow
edited Apr 28 "16 at 6:18
*

techraf
3,33088 gold badges1818 silver badges4040 bronze badges
asked Apr 28 "16 at 0:25
*

NicolasPPNicolasPP
14911 silver badge1111 bronze badges
3
Add a comment |

2 Answers 2


Active Oldest Votes
3
Ok, thank you Batman for arguing to edit the sudoer file. Instead of crontab or launchd to schedule it once a day (which wasn"t good enough anyway), I instead composed that jiyuushikan.orgscript to do it even more consistently and also so far it appears to be working:

repeat repeat attempt perform shell script "ping -t 15 8.8.8.8" departure repeat on error display notification "Relink attempt" execute shell manuscript "superform networksetup -setnetworkservicepermitted ethernet off" do shell manuscript "superform networksetup -setnetworkserviceallowed ethernet on" delay 9 display screen notice "Connection need to be established" finish attempt finish repeat delay 5finish repeatI"m adding more details: I exported it as an .app then I edited the .plist of it with the lines:

LSBackgroundOnly1To make it invisible once it runs (no dock icon) and also finally I made it run on login.


Share
Improve this answer
Follow
edited Aug 25 "16 at 13:45
answered Aug 16 "16 at 11:38
*

NicolasPPNicolasPP
14911 silver badge1111 bronze badges
Add a comment |
1
suexecute allows you to run a command at an elevated permission level. You deserve to edit the sudoers file by running

superform visudoOne means to carry out this is to initially add a line to your sudoers file which allows the listed commands to be run without a password. By adding the particular command also to your sudoers file, you can allow the wanted regulates to be run without password. You deserve to perform this by entering the following 2 lines to your sudoers file (the file that opens once you run "sucarry out visudo"):

user ALL=(ALL) NOPASSWD: /usr/sbin/networksetup -setnetworkserviceallowed ethernet onuser ALL=(ALL) NOPASSWD: /usr/sbin/networksetup -setnetworkserviceenabled ethernet off

through "user" reinserted by your user name.

See more: If You Forgot Your Apple Id Not Found Or Incorrect, Apple Id Not Found

Then, as your user, to run something at a constant time, you deserve to usage crontab

crontab -e

and also appfinish the lines:

0 1 * * * suexecute networksetup -setnetworkserviceallowed ethernet off && sudo networksetup -setnetworkservicepermitted ethernet on

which will certainly use this rebegin at 1 AM eincredibly day.

Anvarious other solution:Add the commands directly to root"s crontab:

suexecute -s

crontab -e

Then enter the line

0 1 * * * networksetup -setnetworkservicepermitted ethernet off && networksetup -setnetworkserviceenabled ethernet on

and also save and departure.

See more: Macbook Screen Brightness Button Not Working Mac 2011 Screen Brightness Issue

You may want to put this in some sort of script that informs you that the network has been properly restarted (e.g. through an e-mail or something) so that you"re certain it operated.