• 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: convert AS syntax to CLI
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: convert AS syntax to CLI


  • Subject: Re: convert AS syntax to CLI
  • From: Justin Middleton <email@hidden>
  • Date: Thu, 15 Sep 2005 23:50:25 -0700

Jeremy,

The feasibility (and sensibility) of moving your AppleScripts entirely over to shell scripts depends to a large extent upon what you're doing. If your scripts are performing rather simple operations, like moving around in the filesystem, reading/writing/ processing text files, or starting/stopping processes, then shell scripts might make sense (and if they're startup/shutdown scripts for always-running daemons, then SystemStarter scripts might be the way to go). However, if your scripts are throwing a bunch of AppleEvents around between apps, you'll want to stick with AppleScript for those bits. And then of course, there's nothing wrong with a hybrid solution... creating a library of shell-script wrappers of AppleScript functionality (each of the wrappers calling AppleScripts with osascript).

In other words, there are many ways to skin it, depending upon what the particular "it" is. The example you provide would be easy to do in bourne/bash.

If you're interested in shell programming, one of the books I highly recommend is "Portable Shell Programming: An Extensive Collection of Bourne Shell Examples" by Bruce Blinn (http://tinyurl.com/cc3bw). This book does not cover bash specifics ("bash", the default shell on OSX as of late, is the "Bourne Again SHell"), but some would say you'd be better for it. The book emphasizes portable ways of performing common tasks. Mine is well-dog-eared. Just about any script you write in plain-old-Bourne will run in bash**.

For a bash specific book, O'Reilly's "Learning The bash Shell, 2nd Ed." by Newham and Rosenblatt (http://www.oreilly.com/catalog/ bash2/), has been recommended to me. I cannot vouch for that particular title, but my experience with O'Reilly is that I can count on them about 80% of the time.

Hope that helps. If you have questions on a specific script, feel free to post it.

/j

** I'm fibbing, a little. bash does some annoying things in the spirit of "helping."

On Sep 15, 2005, at 1:40 PM, Jeramey Valley wrote:

I'm finding that I need to get many of the functions I've used AppleScript for to now work in a shell script. A lot of the tools and the way I need to run them have to run in a shell script as I can't call an application for the functions. Mainly it's during login/out that this needs to do.
Question is: Does anyone have resources to recommend that would help in "converting" the syntax from an AS to a shell script?
Things like comparing the contents of two folders and taking action on the non-matching files in one of those folders. Pretty simple in AS. I don't know how to do this in Terminal or a shell script. I'd rather not do perl or some actual language.


For now I'm getting by with using osascript to call my AppleScripts, which is very functional so far.

Any pointers appreciated.
--

Regards,

Jeramey Valley
email@hidden
Network Administrator
H. H. Dow High School
Midland Public Schools
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
40mac.com


This email sent to email@hidden


_______________________________________________ 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
References: 
 >convert AS syntax to CLI (From: Jeramey Valley <email@hidden>)

  • Prev by Date: RE: How to deal with Asynchronous Finder operations
  • Next by Date: Re: a numeric bug.
  • Previous by thread: convert AS syntax to CLI
  • Next by thread: Re: convert AS syntax to CLI
  • Index(es):
    • Date
    • Thread