Re: AppleScript and shell scripting
Re: AppleScript and shell scripting
- Subject: Re: AppleScript and shell scripting
- From: Bill Briggs <email@hidden>
- Date: Thu, 26 Jul 2007 23:14:38 -0300
At 5:14 PM -0400 7/26/07, J. Stewart wrote:
>Quite a few of the shell's commands are interactive which won't even work correctly via "do shell script"
Well, that's not always the case. You can still use an interactive tool like bc by issuing a shell command that simply echoes the string of commands you want to pass (and there can be several in sequence, separated by semicolons) and pipes the echoed string to bc, which returns the result without entering interactive mode. I use it this way every day with TypeIt4Me triggering AppleScripts that call shell commands that pipe to bc and return the results to AppleScript to be displayed in a dialog box and put on the clipboard. Phew. But it's no big deal. It just works. And since AppleScript won't give me really big binomial coefficients without a lot of extra effort (and it's slow), and the syntax for bc is drop-dead easy, what's a poor lad to do? Surely it's NOT to code that in AppleScript. You'd have to be masochistic.
So yeah, sometimes you can even get away with that sort of thing when interactive mode is the "normal" way to use the tool. But maybe bc is unusual. Because bc has a variable called "last", which functions like "result" in AppleScript, you can chain commands in the echoed statement to great effect. There's more to it, but you get the idea.
I use AppleScript daily, but it's not the solution for every problem, and the shell has a bag full of finely honed tools that have been refined, some of them over 30+ years. Who can afford to ignore them? Just learning the basics of regular expressions has a payback that you can't calculate. Even my mail client (Eudora) allows for regular expressions searches (can you do that in Mail?). It's just too useful to ignore.
- web
_______________________________________________
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