is there a separator so you can put several statements all on one line?
i’m setting up a cron call to an applescript. i don’t want to save the applescript then call that as an application, but i’m going to use the format like: osascript -l AppleScript -e 'tell Application “Finder” to display dialog “punch in” ’
but i want to make it interactive now, and need multiple statements. seems i saw somewhere a long time back that you can use a special character to put multiple statements all on one line of text.
First, if you make ‘several AppleScript calls’ you should be aware that each one runs in its own space. Variables, properties, etc. in one call are completely independent from, and unknown to another osascript call, so that probably won’t work.
Second, why is writing to a file and running that ‘super clunky’?
If you save the script as a compiled script you can call that via osascript (‘osascript /path/to/scpt’). This has several distinct advantages - first you can use Script Editor (or similar) to write, edit, compile and test your script (a lot easier to do here than in the command line), and secondly it will be much faster since osascript won’t have to compile the script each time it’s run.
the whole thing was about making a ‘one liner’ so i can put it in cron via cronnix, and call it every morning.
imo, writing one script’s results to a file and handing data between different applescripts or more work/less elegant than just saving the applescript as an app, and using a shell one liner to execute it.
so i’ve compromised: i just made the 4 line applescript into a run only app. i have a one-liner shell script call it every morning from cron. seems to me to be the simplest/quickest way of doing it.
You may be able to use ‘run script’ to run a multi line script. What you do is place your script within quotes, then you run script the text. I don’t know how to format this in unix at the moment, but I’m thinking it can be done.
Rob, your code would work, but only because you’re not passing any data between the different osascript commands. In effect you’re running one script that activates the Finder, and another script that tells the Finder to display a dialog.
When the second script runs it’s as much coincidence that the Finder is active.
If you consider the following snippet you’ll see that this doesn’t hold true for more complex scripts involving variables: