I am having a hell of a time trying to Sudo with an AppleScript.
Heres the code…
do shell script “sudo ifconfig en0 down; sudo ifconfig en0 up”
When executed, it says AppleScript Error password: password: . Any ideas how this can be done to automate the password? I have tried everything I know, and to no avail. Oh, thanks for your help in advance
METHOD #2, a little bit more secure:
If you’re not worried about ANYONE doing sudo ipconfig’s without a password (it has to be your username anyway so not much of a concern there) on your system, you can have sudo automatically run it without a password. Here’s how!
$ sudo visudo password:
You’ll be presented with the /etc/sudoers file in vi.
# sudoers file. # # This file MUST be edited with the 'visudo' command as root. # # See the sudoers man page for the details on how to write a sudoers file. # # Host alias specification # User alias specification # Cmnd alias specification # Defaults specification # User privilege specification root ALL=(ALL) ALL %admin ALL=(ALL) ALL
Type “i” without the quotes. Hit the down arrow key until you get to the bottom and the right arrow key until you get to the end of that line, then hit enter in order to add the line:
This should be like on my machine:
Hit the escape key.
Type “:w” to save the file.
Type “:q” to quit.
You should be good. You can e-mail me if you’ve any problems.
Thanks to cello for some vi tutorial, as I had forgotten much of vi.
The Mac Coaster
Quad Core Q6600 PC, 23″ Apple Cinema HD LCD, White MacBook C2D 2.16 GHz, Athlon64 PC, AthlonXP PC, iPod photo 60 GB