• 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 00:38:24 -0700

On Feb 15, 2005, at 5:57 PM, Bill Briggs wrote:


 You can coax that error to come back to AppleScript if you do a bit of shell redirection. The shell has three "files" it uses, apart from the files you explicitly name in your file system. Standard Input is 0, Standard Output is 1, Standard Error is 2. You can redirect these, and in this case you want to redirect Std Error back to Standard Output so it'll be fed back to the Script Editor (which I assume at this point only gets fed Std Out when the script completes (or not)). If you use this command.


do shell script "pmset -a ams 0 2>&1"  password "wrongpword" with administrator privileges

 you should get the error message when you feed it a bogus password. I used a different parameter but fed it the wrong password and got the error back by doing this:

do shell script "pmset -c spindown 30 2>&1" password "wrongpword" with administrator privileges

Try that on your machine and you should get the error kicked back if you issue the shell an incorrect password.

It doesn't return an error to the script.

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 text returned of (display dialog "Enter your password." default answer "")
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


Here's the log:

tell current application
display dialog "Do you want Sudden Motion Sensor turned on or off?" buttons {"On", "Off", "Cancel"} default button "Cancel"
{button returned:"On"}
display dialog "Enter your password." default answer ""
{text returned:"dfsds54", button returned:"OK"}
do shell script "pmset -a ams 1 2>&1" password "dfsds54" with administrator privileges
""
end tell


--
There's no place like 127.0.0.1
There's no place like 127.0.0.1
There's no place like 127.0.0.1

_______________________________________________
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


  • Follow-Ups:
    • Re: do shell script
      • From: Bill Briggs <email@hidden>
References: 
 >do shell script (From: Michelle Steiner <email@hidden>)
 >Re: do shell script (From: Bill Briggs <email@hidden>)
 >Re: do shell script (From: Michelle Steiner <email@hidden>)
 >Re: do shell script (From: Bill Briggs <email@hidden>)

  • Prev by Date: Re: question about behaviour of Appleworks save.
  • Next by Date: path to confusion
  • Previous by thread: Re: do shell script
  • Next by thread: Re: do shell script
  • Index(es):
    • Date
    • Thread