• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: do shell script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: do shell script


  • Subject: Re: do shell script
  • From: Michelle Steiner <email@hidden>
  • Date: Wed, 16 Feb 2005 13:08:21 -0700

On Feb 16, 2005, at 12:47 PM, Andrew Oliver wrote:

I figured this out. If you enter a correct password, then when you
subsequently run it with a wrong password, it does not return the error
until you quit the script and run it again, using a wrong password the
first time--but if you ever enter the correct password, it will no
longer return the error.

This is more likely to be a timing issue than a 'quit and restart' fix.

'with administrator privileges' currently uses sudo (see Chris' recent
note), sudo maintains a timeout for each user such that subsequent 'sudo'
commands do not require re-authentication. I'm guessing that subsequent 'do
shell scripts' within that timeout don't pass the 'incorrect' password since
no password is required anyway (either that or it does pass the password
which sudo silently ignores)

I was about to post that it was more complex than I had thought because the quit and restart didn't work, even with quitting Script editor completely.


Thanks for the explanation.

Here is what I hope is the final version of the script:

set PWDMessage to "What is your password?"
display dialog "Do you want Sudden Motion Sensor turned on or off?" buttons {"On", "Off", "Cancel"} default button "Cancel"
set button_reply to button returned of the result
set pword to setPWD(PWDMessage, button_reply)


on setPWD(prompt, button_reply)
	set pword to text returned of (display dialog prompt default answer "")
	my setMotion(pword, button_reply)
end setPWD

on setMotion(pword, button_reply)
try
if button_reply is "Off" then
do shell script "pmset -a ams 0 2>&1" password pword with administrator privileges
else if button_reply is "On" then
do shell script "pmset -a ams 1 2>&1" password pword with administrator privileges
end if

on error msg
set pwdmsg to "The password was incorrect." & return & "Please enter your password."
my setPWD(pwdmsg, button_reply)
end try
end setMotion


-- Michelle

--
Those who extol the "nobility of labor" mean the labor of others.

_______________________________________________
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


References: 
 >Re: do shell script (From: Andrew Oliver <email@hidden>)

  • Prev by Date: Re: do shell script
  • Next by Date: Emergency notification
  • Previous by thread: Re: do shell script
  • Next by thread: Re: do shell script
  • Index(es):
    • Date
    • Thread