using sudo in shell?

Sarah Reichelt sarah.reichelt at gmail.com
Mon Jun 26 14:54:49 EDT 2006


On 6/26/06, Richard Gaskin <ambassador at fourthworld.com> wrote:
> Sarah Reichelt wrote:
>
> > On 6/26/06, Ben Rubinstein <benr_mc at cogapp.com> wrote:
> >> I don't even know if this is a Rev question, or a bash question, or an OS X
> >> question.  But does anybody know of a way that one can in effect pass a
> >> password to shell in this situation, or in any other way get round this problem?
> >
> > Here is how I do it (this example sets the system clock):
> >
> >  put "#!/bin/sh" & cr into tScript
> >  put "pw=" & quote & tPass & quote & cr after tScript
> >  put "echo $pw | sudo -S date " & tDate & tTime & cr after tScript
> > -- build the command lines, the command you need to run goes after the -S
> >  put shell(tScript) into tCheck  -- do the command & get the result
> >
> > You have to quote your admin password, but you can ask for that when
> > running the script, or store it in a custom property.
>
> FWIW, I believe this only works when logged in with an administrator
> account.
>
> I recently took the advice of some Unix security gurus and stated using
> a non-admin account for most day-to-day work.  While for the most part I
> barely notice the difference, I do find that things like sudo, which
> worked easily when I had used an admin account, now require me to log in
> as admin before I can execute them.
>
> Thankfully, with OS X's "Fast user switching" it's not only easy, but
> with the rotating cube effect it's also fun. :)

I think sudo has an option to allow you to enter the name of the user
you want to use. I don't know the exact syntax, but open the Terminal
and type "man sudo".

Cheers,
Sarah

P.S. Ben, I don't see anything wrong with the one liner.



More information about the use-livecode mailing list