• 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: Wed, 24 Aug 2005 19:01:52 +0200

Op 24-aug-2005, om 18:22 heeft applescript-users- email@hidden het volgende geschreven:

Your way of detecting running via osascript(1) is fairly clever, but
consider:

1. It'll only work in Tiger and later, since before then, osascript
(1) didn't pass arguments to the script.

My script is intended for use with Mail 2, so I know it will be used on Tiger.
Would the construct


    on run arguments
        if (class of arguments = list) then
        ...

cause problems on Panther?

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

    on run arguments
        if (exists arguments) then
        ...

but I can't seem to ask a list if it extist. I guess my newbe status shines through in these questions...

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


If interaction isn't allowed, commands that try to interact will
throw an error, which you can catch and handle with a "try" block.
For example:

     try
         display dialog "Hello, world!"
     on error e
         return "You must be running this from Terminal.  " & e
     end try

That seems a good approach. I'll have to see how it fits my design. The functionality of the command line branch of my script is a bit more limited than the gui enabled part.


P.S.: As for the Language Guide not mentioning osascript, well
naturally -- Mac OS X didn't exist in a public form when the ASLG was
last updated. =)  Go ahead and file a bug on that, though (mentioning
osascript, not the general need to update it), so that way it won't
get lost.

I'll ask for a mention of osascript in the guide. I'm allways a bit apprehensive about using technology for which the manual hasn't been updated for _ages_, but I guess you could say the same about JavaScript, and that still working...


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: Select Finder items by Regular Expression
  • Next by Date: Re: Select Finder items by Regular Expression
  • 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