• 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
Osascript timesaving tip
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Osascript timesaving tip


  • Subject: Osascript timesaving tip
  • From: Martin Orpen <email@hidden>
  • Date: Tue, 04 May 2004 10:35:03 +0100

I've just posted a osascript tip to macosxhints - but thought I'd run it
past the group first to see what you think.

I got really fed up with having to use osascript -e when running
applescripts remotely via the Terminal.

So I thought that I'd give the redirect command a try - thus allowing me to
type and view the script in a way that is much easier to bugfix than a
single line.

So to run a remote script I now do:

$ cat << done | osascript

And on hitting enter I get a new prompt which allows me to enter the script
line-by-line and then finish with whatever word I choose to indicate that
the input has ended (in this case done).

What I like about this method is the fact that I can cut and paste huge
scripts into the Terminal window and have them run right away :-)

NB: the Terminal will choke on tabbed lines like the "set end..." one below:

set volumeNames to {}
repeat with i from 1 to (count of disks)
set end of volumeNames to name of disk i
end repeat

But all you need to do is *remove all of the indents* before pasting the
script into the Terminal window.

If you don't fancy running the script immediately, you can easily adapt the
commands to save the script to disk first and then run the file:

$ cat << done > myScript.txt

$ osascript < myScript.txt


Apologies if this has been covered before - but it has saved me a load of
typing this weekend :-)

Regards

--
Martin Orpen
Idea Digital Imaging Ltd -- The Image Specialists
http://www.idea-digital.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Osascript timesaving tip
      • From: Steven Majewski <email@hidden>
    • Re: Osascript timesaving tip
      • From: Axel Luttgens <email@hidden>
  • Prev by Date: Re: Possible bug.
  • Next by Date: Re: Possible bug.
  • Previous by thread: Re: Changing Spelling Dictionary?
  • Next by thread: Re: Osascript timesaving tip
  • Index(es):
    • Date
    • Thread