• 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: [newby] Detect if a script was started from the command line
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [newby] Detect if a script was started from the command line


  • Subject: Re: [newby] Detect if a script was started from the command line
  • From: patrick machielse <email@hidden>
  • Date: Thu, 25 Aug 2005 16:43:24 +0200


Op 25-aug-2005, om 16:04 heeft applescript-users- email@hidden het volgende geschreven:


On Aug 24, 2005, at 10:01 AM, patrick machielse wrote:

Also, if I run from the Script Editor I see that the class of
arguments is 'script'. How should I interpret that?

It means that "arguments" is a script object. As it happens, it's the top-level script object, the same thing as "me" in that context.

So (at least on Tiger) I could test like this:

    on run argv
        if argv = me then
            -- not started from the command line

Somehow that scares me...

As it happens I only need to branch in my script if an argument was passed on the command line, so I think I can get away with testing like so:

    on run argv
        if (class of argv = list) and ((count of argv) > 0) then
            -- use the argument
        else
            -- use 'try' around gui code and catch errors

2. There are other ways for your script to be run without interaction
allowed; running from osascript is merely the most common one.

I'm interested to know any other scenario's (executing over a network connection?)

I'll admit that this is more a theoretical case than an actual one. An application can request to not have any user interaction when running a script, or it could implicitly be forced to do that because it's background-only, but almost no one does that -- osascript is one of the only cases.

If I understand you correctly: If I have an application that sets LSUIElement 1 in its Info.plist, display dialog will fail if it tries to execute that in an AppleScript file? Nice.


patrick
_______________________________________________
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: [newby] Detect if a script was started from the command line
      • From: Christopher Nebel <email@hidden>
  • Prev by Date: Re: run script from browser
  • Next by Date: Re: Folder action to rename files
  • Previous by thread: Re: [newby] Detect if a script was started from the command line
  • Next by thread: Re: [newby] Detect if a script was started from the command line
  • Index(es):
    • Date
    • Thread