• 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: osascript and *.command files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: osascript and *.command files


  • Subject: Re: osascript and *.command files
  • From: Thomas Treichl <email@hidden>
  • Date: Wed, 10 Oct 2007 18:21:56 +0200

Axel Luttgens schrieb:
On 7/10/07 18:25, Thomas Treichl wrote:
Axel Luttgens schrieb:

[...]
What happens if you run the .command file directly, e.g. by typing:

~/Desktop/other.command


Sure that works.

After all, the .command file is just a regular shell script, and Terminal.app is already opened.


It seems to be not, because shell scripts can be called without any problem. I expect the problem is somewhere in the osascript part of the example file but I don't know for sure.


Strictly speaking, it _is_ a regular shell script; the fact that its name ends with .command doesn't mean that it _must_ be run with the help of the "open" shell tool.

Yes sure - it was meant a little bit ironic ;o)

<SNIP>
I still don't have a clear view of the way you need to organize your workflow, so forgive me if I'm just erring...

But perhaps could you reverse the logics.

Let's start with your the core of your example:

   tell application "Terminal"
     activate
     do script "ls"
   end tell

and save it now as an applet, say ~/Desktop/test.app.

It may even be somewhat enhanced, so as to avoid all those windows:

   tell application "Terminal"
       launch
       activate
       if (count of windows) > 0 then
           do script "ls" in window 1
       else
           do script "ls"
       end if
   end tell

Each double-click on its icon will execute "ls" in Terminal.app's front window.

The same way, it may be invoked as often as needed from a shell script or from the command line with:
open ~/Desktop/test.app


So, your users may now have a "double-clickable solution".

If it wouldn't be the problem with the *.command files I would say yes ;) The problem is that I can't say to the users modify all your *.command files into *.app files.


But this still doesn't solve the problem related to .command files: even with the above arrangement, they won't have any effect anymore when double-clicked.
In fact, the problem seems to be with Terminal.app itself wrt Apple Events, not with osascript nor the Finder nor LaunchServices etc.
As a "proof", save this script
#!/bin/sh
ls
as ~/Desktop/test1.command.
Assuming Terminal.app is not running, a double-click on test1.command will launch Terminal.app as expected; each subsequent double-click will be functional too.
Now, in Script Editor, just execute:
tell application "Terminal" to get properties
Poof! Double-clicking on test1.command doesn't have any effect any more...


HTH,
Axel

This exactly addresses my problem. So what can I do now? Enter the bugreporter and paste our discussion there?


Thanks for your help Axel,

  Thomas
_______________________________________________
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: 
 >osascript and *.command files (From: Thomas Treichl <email@hidden>)
 >Re: osascript and *.command files (From: Axel Luttgens <email@hidden>)
 >Re: osascript and *.command files (From: Thomas Treichl <email@hidden>)
 >Re: osascript and *.command files (From: Axel Luttgens <email@hidden>)

  • Prev by Date: Re: osascript and *.command files
  • Next by Date: Address Book custom fields?
  • Previous by thread: Re: osascript and *.command files
  • Next by thread: Trouble with Remote Apple Events (eppc) and Keychain
  • Index(es):
    • Date
    • Thread