(* middleMan -- a demonstration of 'stay-open' script possibilities, by Robert Elliott Simms, 5-Feb-2004 to find e-mail, my personal web page and Google should suffice (or your basic spammer's toolkit CD) 1) accept commands via the Mac OS X osascript command. 2) update a status indicator (complements of Extra Suites) 3) be able to quit via osascript or Command-Q (or dismissal of status indicator) 4) return information upon request via osascript 5) how to do a 'display dialog' without permanently blocking quitting 6) feel out what does or doesn't cause the 'No user interaction allowed' error. Unless you want to comment out the "Extra Suites" commands, you can download it from http://www.kanzu.com/ -- a shareware program that works. It just requires a drag-and-drop install. Paste this script into a blank Script Editor document. Save the script as an application with properties: DO stay-open, DON'T DO startup screen Then use commands like: osascript -e 'tell app "middleMan" to activate' osascript -e 'tell app "middleMan" to do("finish the laundry")' osascript -e 'tell app "middleMan" to do("walk the dog")' osascript -e 'tell app "middleMan" to do("do my homework")' osascript -e 'tell app "middleMan" to do("take a test for me")' osascript -e 'tell app "middleMan" to showList()' osascript -e 'tell app "middleMan" to doApp1()' osascript -e 'ignoring application responses\ tell app "middleMan" to quit\ end ignoring' Note: you can copy and paste these commands into a terminal window all at once ;-) The above all worked fine whether in a local shell or logged in via SSH. *) global howMany, taskLimit, taskList, CR on run -- initialization of some variables set CR to return as text set taskList to {} set howMany to 0 set taskLimit to 3 -- set up a progress indicator tell application "Extra Suites" ES display progress counting to taskLimit top 100 left 100 with caption "osascript -e 'tell app \"middleMan\" to do(\"\")'" end tell end run -- see if we can invoke this remotely without getting the user interaction error on doApp1() -- use 'ignoring' so that we don't have to wait for the application to finish activating ignoring application responses tell application "Grab" to activate end ignoring end doApp1 on doApp2() -- this is to attempt to run an AppleScript saved as an application. -- it's a simple one that will knowingly interfere with the operation of this script. tell application "Quit Extra Suites" to activate end doApp2 on do(theMessage) if howMany is taskLimit then return "Ask again when I'm another process." end if set howMany to howMany + 1 -- for a nice effect, a string parser could be added -- that would switch word pairs in theMessage like these: -- you <--> me -- your <--> my set taskList to taskList & theMessage -- even with this next line, we don't get a "No user interaction allowed" error when this script is invoked with osascript (*tell application "Grab" to activate*) -- So it seems that doing a 'tell' that causes the choose-app dialog -- to pop up causes the error "No user interaction allowed." -- That happens when a script is run/compiled for the -- first time on a machine. -- an alternate way of acknowledging the request (*say theMessage*) tell application "Extra Suites" set userCancelled to ES advance progress by 1 updating caption to  (howMany as string) & " request" & my ess(howMany) &  ", latest: " & theMessage end tell if userCancelled then quit end do on showList() set AppleScript's text item delimiters to "; " -- just to show it can be other than a comma return (taskList as string) end showList on ess(n) if n is 1 then return "" else return "s" end if end ess on idle beep -- simply to demonstrate the script can do something regularly on its own tell application "Extra Suites" set userCancelled to ES advance progress by 0 end tell if userCancelled then quit return 6 -- seconds until 'idle' is called again; default is supposedly 30 end idle on quit -- gotta bring this script to the front to proceed with the following dialog. -- assume anyone sitting at the computer doesn't know this. tell me to activate display dialog "number of requests: " & howMany giving up after 5 ignoring application responses tell application "Extra Suites" to quit end ignoring -- must hand off quitting to parent for it to succeed. continue quit end quit