Hi All,
I am developing a application which requires the execution of terminal commands.I am using “Do Shell SCript” to execute the commands.The code is use is
do shell script “sudo cp /etc /etc1” .This command prompts a password .my problem is
When i write a script is it possible to disable the password prompt.
The above command does not prompt for password in one machine and in another machine i am testing it prompts.
There is no need to disable the sudo password, you can store the password in your script (not recommended, but you can)
do shell script "sudo cp /etc /etc1" password "your-password" with administrator privileges
Does copying the /etc directory really require a password?
Are you logged in as ‘root’ on the other machine? Also, ‘sudo’ has a timestamp of 5 minutes which may be why it appears to working on one machine and not the other.
See “man sudo” and “man sudoers” in the terminal.app for more info.
Hi ,
Thanks for the reply.I used the command without success.i m using applescript to configure stunnel in my machine.the script i use is
do shell script “cd;sudo stunnel -c -p stunnel.pem localhost:139 -r 64.11.191.232:3000 password " & variable & " with administrator privileges”
yes, when using sudo, yo can only issue one command in do shell script. There is a technote @ Apple.com about using ‘do shell script’ and ‘sudo’, but I’ve not been able to find it.
I’m not familiar with ‘stunnel’, but your command has a “cd;” in front of the “sudo stunnel -c” command. You can use the semicolon ( ; ) to separate commands on the same line, but you are ‘cd’ing’ to the command “stunnel -c” which should give you an error. Also the syntax is incorrect for the password part of your script…
If ‘stunnel’ is not in your executable path, then you should use a path relative to the command
do shell script "sudo /path/to/stunnel -c -p stunnel.pem localhost:139 -r 64.11.191.232:3000" password """ & variable & """ with administrator privileges
Question, why are you using a variable for the password? If you have to type in a password somewhere, why don’t you let the System handle that. Like this…