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

Problem with osascript command


  • Subject: Problem with osascript command
  • From: Mike Kobb <email@hidden>
  • Date: Mon, 26 Nov 2007 15:20:39 -0800

Hi!

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).

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?
_______________________________________________
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
  • Follow-Ups:
    • Re: Problem with osascript command
      • From: Christopher Nebel <email@hidden>
    • Re: Problem with osascript command
      • From: Philip Aker <email@hidden>
    • Repeat until ...the user chooses to stop?
      • From: Dane Springmeyer <email@hidden>
    • Re: Problem with osascript command -- clarification
      • From: Mike Kobb <email@hidden>
  • Prev by Date: Re: Script Editor rewrites/code conflict
  • Next by Date: Visualhub and folder watching automation
  • Previous by thread: Re: Script Editor rewrites/code conflict
  • Next by thread: Re: Problem with osascript command -- clarification
  • Index(es):
    • Date
    • Thread