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

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


  • Subject: [newby] Detect if a script was started from the command line
  • From: patrick machielse <email@hidden>
  • Date: Wed, 24 Aug 2005 11:06:52 +0200

I'm new to this list and new to AppleScript.

I whipped up a script that _might_ be started from the command line. I believe that if it is started in this way I cannot have any user interaction, (I couldn't find any reference to 'command line' or osascript in the AppleScript Language Guide (anno 1999). Maybe I should file a bug...) so if the script is launched using osascript I want it to not use any dialogs.

I use the following code to determine if the script was started from the command line:

on run arguments
    if (class of arguments = list) then
        --  started from the command line
        --  non interactive code goes here
        return
    end if
    --  regular code using dialogs goes here
end run

When the script is run from Script Editor the class of arguments seems to be 'script'. Is this a robust way of checking the way in which the script was started, or is there a better way?

patrick

---
Tonight we're go'na script like it's 1999.
Prince

(or: when will the language guide be updated?)

_______________________________________________
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: Are you busy? info for file while copying
  • Next by Date: Fwd: Mail and Attachments
  • Previous by thread: Re: Retrieve email attachments
  • Next by thread: Re: [newby] Detect if a script was started from the command line
  • Index(es):
    • Date
    • Thread