Shell

Sarah Reichelt sarah.reichelt at gmail.com
Wed Oct 4 05:51:04 CDT 2006


On 10/4/06, Hershel Fisch <hershf at rgllc.us> wrote:
> Hi, I'd greatly appreciate if some one can help me out on this one.
> How do I write this command with the shell function, I would write it in
> terminal as follows
>
> Su -  myUsr
> Password:
> And another command.
>
> Now the question is that every line above is a different entry
> If I put
> Put shell("su - myUsr") in the message box this is the result
> "Password's: Sorry"
>
> And also if I understand correctly every command with the shell function is
> a different terminal and does not correspond to the previous shell reply, is
> that true? If so how do I write that every command should correspond to the
> previously respond?


You have to construct the shell commands as a single string and do it
all at once. Here's an example of how to use sudo to set the system
clock, but just put whatever you want after the "-S".

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