View Full Version : Shell scripting
jwfische
04-03-2005, 02:13 AM
I need to do some scripting for Macs but my current knowledge in programing in this field is quite a bit less then lacking. I need to write 2 scripts and have really no idea how to go about doing them.
Both need to auto start at a certain time, run a program and then terminate some time later.
the other script needs to activate/run (whatever the term is) a series of key strokes, this is the part that I'm yet to find out if it's possible.
if you can help I'd greatly appreciate it, thanks
fischerm
04-03-2005, 08:42 AM
Running a script at a particular time is fairly easy with unix cron. This lets you run programs on pretty much any recurring time. Every other monday at 12:00am, every day at 8:00pm, etc.
You can launch the app directly from within the cron command, MacOS X has a unix command called 'open' that does whatever double-clicking on it in the finder would do, so for an app it would launch it. So for example if you wanted to launch the calculator, you would use the command 'open /Applications/Calculator.app' the calculator should launch in the finder.
There's no 'close' command that works in the way you'd like however. It's possible for you to kill the process, but that's messy. I would write an applescript that just does:tell application "calculator"
quit
end tellSave the applescript as a runnable application, then use 'open /Path/To/Your/CloseCalculator.scpt' to run the applescript, thus quitting the calculator (or whatever app).
I can't think of how to do keystrokes off the top of my head. There used to be a program called QuickKeys that did pretty much anything imaginable, and could probably do this, but I'd have to look into it more. It's also quite possible you can do keyboard strokes from applescript.
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.