Re: do shell script
Re: do shell script
- Subject: Re: do shell script
- From: Michelle Steiner <email@hidden>
- Date: Tue, 15 Feb 2005 13:41:28 -0700
On Feb 15, 2005, at 1:32 PM, Bill Briggs wrote:
At 12:45 PM -0700 2/15/05, Michelle Steiner wrote:
How do you include the admin password in do shell script?
For instance, this requires a password:
do shell script "sudo pmset -a ams 0"
If you include sudo in the string handed to do shell script, and you also include ' with administrator privileges password "supersecret" ' you may find the process with hang your Script Editor. I doesn't do it all the time on my Mac, but if the shell script is one that spawns a child shell it always does.
Do you mean that including "sudo" in the shell script and adding "with administrator privileges is redundant, and that one or the other can be eliminated?
Here is the script so far.
property : missing value
display dialog "Do you want Sudden Motion Sensor turned on or off?" buttons {"", "", ""} default button ""
set to button returned of the result
if is missing value then
set to text returned of (display dialog "Enter your password." default answer "")
end if
if is "" then
do shell script "sudo pmset -a ams 0" password with administrator privileges
else if is "" then
do shell script "sudo pmset -a ams 1" password with administrator privileges
end if
Not having the right machine, I can't test the script, though.
I did find that if I used an incorrect password, it does not return an error. I do need to add code to let the user change the password once it is stored, or else require her to type it every time.
BTW, this script was prompted by someone posting to one of the Mac web sites that Apple did not offer a utility to turn the sudden motion sensor on or off. I took the code within the shell script from a knowledge base article.
-- Michelle (being dragged slowly, not entirely willingly, into shell scripting <g>)
--
Whoever said the last man standing is the winner didn't invite the girl.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden