Re: combining Applescript and CLI/cron jobs
Re: combining Applescript and CLI/cron jobs
- Subject: Re: combining Applescript and CLI/cron jobs
- From: Clark Goble <email@hidden>
- Date: Fri, 22 Aug 2003 15:29:18 -0600
On Tuesday, August 19, 2003, at 09:58 PM, Bert Knabe wrote:
___ Bert ___
| I want to write two scripts that will run at set times.
| I don't know much about Applescript, but I know nothing
| about creating cron jobs.
___
As a few others mentioned, "man cron" will give some help and Cronnix
is a nice GUI for it. (Something Apple really ought to provide - and
even Cronnix is a little rough around the edges) O'Reilly has a nice
tutorial on using Cron on the Mac as well.
http://www.macdevcenter.com/pub/a/mac/2001/12/14/terminal_one.html
Depending upon what you are doing though you might want to consider
anacron, available as part of Fink. I don't know if you have Fink, but
if you are writing combination Applescript/Shell scripts, it is very
helpful. I'll mention it again later.
http://fink.sourceforge.net/index.php
The reason anacron is better than the standard cron is that anacron
checks to see if the machine has been off and runs scripts that should
have run but couldn't because the machine was turned off. If you are
using your scripts for automated workflow, you might need scripts to
update if the system had been off for some reason. This is less of an
issue if you leave your computer on all the time. And, to be honest,
based upon your descriptions it probably wouldn't affect your scripts
that much.
___ Bert ___
| It will copy files from one folder to another, start Acrobat
| Distiller, and when the folder the files were copied to is empty,
| close Distiller.
___
One fun thing about Applescript/Shell programming is that it avoids
needing Distiller in some cases. For instance the last Acrobat reader
didn't handle postscript that well. (I believe v. 5 does, but I've
been too lazy to check) I wrote the following Applescript to handle it:
on open input_file
do shell script "export PATH=\"$PATH\":/sw/bin;ps2pdf " & quoted form
of POSIX path of input_file & " /tmp/.psview.tmp.pdf"
do shell script "open /tmp/.psview.tmp.pdf"
end open
I then actually used Get Info in the Finder to associate all files with
.ps extensions to this Applescript. That then opened them.
This is obviously the exact opposite of what you are doing. I just
brought it up because ghostscript has lots of useful things you can do
with it.
___ Bert ___
| It seems to me that Applescript is perfect for the actual
| work, deleting files, copying files and starting/stopping
| a program,
___
I actually think that the shell is actually better and easier for
deleting files, copying files, starting programs and so forth. I
typically only use Applescript when *controlling* applications. For
everything else I find that I can either write a shell script or Python
script that is more efficient. But that's just me. Use the tool that
you are familiar with. This might be a great way to learn Applescript
and the shell.
___ Bert ___
| And lastly, is there a good, up to date book on Applescript that
| includes OS X? If not, what is the best book out there currently?
___
The only good one I know of is O'Reilly's _Applescript in a Nutshell_.
But it is very dated. It is primarily Sys9 and it's OSX stuff was
clearly written with 10.0. A lot of recent additions to Applescript
aren't discussed. The better place to learn is to look at some scripts
and try to figure them out. And, of course this list helps. The best
bet is, of course Google. Second up might be doing a search for
applescript on OSX Hints.
_______________________________________________
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.