sw@nan.co.uk (Sak Wathanasin) (05/26/91)
If you don't use MPW, ignore this. I was playing with Toolserver (from the ETO #3 CD) today (I mean assessing its usefulness :-). ToolServer can run as a "MPW server" on another Mac on a network (responding to remote commands), but can also be used to run jobs in the background on your own Mac. In this mode, it behaves like an MPW shell without the editor. When ToolServer starts up it executes a MinStartup file, which in turn executes a MinUserStartup file etc just like the MPW shell. You then ask it to execute a shell script that you've previously prepared that builds a program (or whatever). While it does this, you can switch back to MPW. Great, but I didn't want to maintain another set of startup scripts. I also wanted to be able to launch jobs into the background on the fly, just like you can with "&" in Unix. I didn't manage to simulate "&", but this simple amalgamation of the MPW "Suspend" script, and the sample script in the ToolServer manual does something like it. --- # Run an MPW script in the background (tabstop = 8) Begin Set Export # Alias # if you use aliases in your scripts, uncomment this line Quote Directory `Directory` Echo 'set done 1' Quote -n {"Parameters"} # for MPW 3.2 # Echo -n "{{Parameters}}" # if you are using MPW 3.3a1 Echo " E BgScript.out || unset done" # E = sigma = option-w Echo 'If {done} ; 6 # 6 = delta = option-d Alert "6"{Parameters}6" finished" ; 6 Else ; 6 Alert "6"{Parameters}6" failed" ; 6 End ' echo Quit End > "{MPWTmp}BgScript" # you need to define a variable MPWTmp ToolServer "{MPWTmp}BgScript" # that points to a folder to put temp files --- Just save it in your scripts folder as (for example) "bg", and then you can do things like (having first cd'ed to the right folder) bg buildprogram foo # fire off a build in the bg I.e., just stick a "bg" in front of your usual commands. When the job is finished, you will be told by the notification manager (toolserver icon flashes alternately with apple icon); error and std output are written to a file "BgScript.out" in the current folder (at the time of launch). Because "bg" exports your current environment, you don't really need the MinStartup script (I use an empty file of that name). ToolServer (and the MinStartup file) has to be in a folder that is on your {Commands} path. It's easy to make the Build menu use "bg". There are a few wrinkles: a) when you execute ToolServer it starts up in the foreground and you have to switch it to the background manually; b) it leaves temp files lying around. I tried a "Quit" script to delete them but the script, error, and output files are still open at this point; c) you have to remember to not to leave src files open in the MPW shell; d) you can only have one bg job at a time; e) ToolServer eats up another 2 MB (but you can reduce the memory allocated to the MPW shell). Also I haven't checked all the weird and wonderful things that happen if you are trying to pass quotes through to "bg". Just keep the command simple. Still, it only took a few minutes to knock together. Hope it's of some use to you. It would be nice if ToolServer had a "Preference" option to open up the status window on startup, or some way of doing this using (for example) the MinStartup script. And if it could stay in the background after launch, and if I had 20 MB RAM, ... Sak Wathanasin Network Analysis Limited uucp: ...!ukc!nan!sw other: sw@network-analysis-ltd.co.uk phone: (+44) 203 419996 snail: 178 Wainbody Ave South, Coventry CV3 6BX, UK
strull@Apple.COM (Brian Strull) (05/29/91)
Some additional ToolServer hints: If you have MPW 3.3 (from ETO #3 and later) and are running system 7, you can use the rshell command to launch tool server and send it a script. It will be launched in the background. On ETO #4, ToolServer has a preference file which remembers if the status window was open, and where it was.