• 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: Problem with osascript command
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with osascript command


  • Subject: Re: Problem with osascript command
  • From: Philip Aker <email@hidden>
  • Date: Mon, 26 Nov 2007 20:28:50 -0800

On 2007-11-26, at 15:20, Mike Kobb wrote:

I'm developing a little script that needs to be executed via osascript.  It's getting run as part of an installer, and its job is to quit System Preferences if it's open.

I've written the script in Script Editor and tested it, and it works fine.  However, when I invoke the same script with osascript, I'm getting incorrect behavior.  I'm hoping somebody can help me.  This is on Leopard, by the way (10.5.1).

I think you might be able to get by with:

killall "System Preferences" 2>/dev/null;



Here's a scaled-down test case of my little script:

-- We refer to applications by id rather than name in case of localization
tell application id "com.apple.systemevents"
set everyProcess to bundle identifier of every process

-- Start by quitting System Preferences, since we're installing a new pref pane
if "com.apple.systempreferences" is in everyProcess then

-- activate first, so that if quitting the app presents a dialog, it will be visible
tell application id "com.apple.systempreferences" to activate
end if
end tell


As I noted, this works fine in Script Editor.  If System Preferences is running, it comes to the front.  If it's not running, nothing happens.

If I save this as a text file, then run it via osascript:

osascript myScript.txt

...then System Preferences launches to handle the "activate" message.

I've tweaked the script to show me the contents of everyProcess, and com.apple.systempreferences is in there.  Am I doing something wrong (e.g. with my "is in" syntax), or...?

I'm sorry if this is a n00b question, but I'm a 20-year C++ programmer working my head around AppleScript. ;-)

Thanks much,
--Mike

PS: I've developed what I think are a couple of very handy scripts for Safari.  Is there a good place to post them?

Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Problem with osascript command (From: Mike Kobb <email@hidden>)

  • Prev by Date: Re: Init Caps Handler
  • Next by Date: Re: "LabVIEW" control broken because of Leopard "Unicode text" (?)
  • Previous by thread: Repeat until ...the user chooses to stop?
  • Next by thread: Re: Problem with osascript command
  • Index(es):
    • Date
    • Thread