Re: [SLUG] shell script question

From: Levi Bard (levi@bard.sytes.net)
Date: Wed Jan 29 2003 - 19:40:41 EST


> > Background: I'm running a shell command in sh via Applescript in Apple's OS X
> > to restart the computer (from OS X to OS 9), but I have to use the sudo
> > command. (We have a lab full of Macs that constantly go back and forth
> > between the OS's)
> >
> > About the sudo command: when you run a shell script in this basic form: sudo
> > <command>, you get a prompt back asking for the password. How do I make the
> > script know that the prompt has appeared, and then fill in the password?
> >
>
> IIRC, in your sudoers file add the following (root@host$ visudo):
>
> <User or User_Alias> <user_to_run_as> = NOPASSWD: <command or
> command_alias>

My line from /etc/sudoers on my home machine looks like:
levi ALL=NOPASSWD:ALL

Additionally, if you have lots of issues like this, where your script needs to respond with prompted information, you might want to take a look at the scripting language expect. It's an extension of tcl, and it's specifically designed to interact on stdin/stdout with applications. For example, I wrote a simple IRC bot in about 20 lines.

Levi



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 13:57:16 EDT