using sudo in shell?

Richard Gaskin ambassador at fourthworld.com
Mon Jun 26 07:25:42 EDT 2006


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. :)

--
  Richard Gaskin
  Managing Editor, revJournal
  _______________________________________________________
  Rev tips, tutorials and more: http://www.revJournal.com



More information about the use-livecode mailing list