using sudo in shell?

Sarah Reichelt sarah.reichelt at gmail.com
Mon Jun 26 05:57:36 EDT 2006


On 6/26/06, Ben Rubinstein <benr_mc at cogapp.com> wrote:
> The 'shell' command is a very useful extension to Rev's native powers.
> However, there are some things, at least on OS X, which I want to do that
> require the shell command to be issued in super-user mode.
>
> Is there any way to make this happen?   If you are working in the terminal,
> you can issue the command as "sudo <x>" and you will be asked for the
> password.  Prefix your parameter to "shell" with "sudo", and the result will
> be the single line prompt "Password:".
>
> 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?

Hi Ben,

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.

HTH,
Sarah



More information about the use-livecode mailing list