HyperCard and shell scripting

nkuitse on 2003-11-22T14:54:35

So I have this HyperCard stack that serves as a CGI backend...

It runs on the 1GHz G4 server that sits in my office, about 18 inches from my computer.

Both machines run Mac OS X. HyperCard runs in Classic (of course).

Since my HyperCard stack requires hands-on intervention any time something goes wrong or I need to make any changes, I find myself scuttling back and forth from time to time.

Needless to say, cutting and pasting from one to the other is out of the question (well, I suppose I could use pbpaste and scp). Writing custom scripts for ad hoc reports, etc. is a problem because the stack runs as a standalone; hence you can't just pull up a card script and edit it.

So I wrote this little shell script...

#!/bin/sh

if [ -z "$1" ]; then args=$(cat <&0) else args="$*" fi

htscript=$( { echo 'lock error dialogs'; echo "$args"; } \ | perl -pe 's/\n/\\r/g; s/"/\\"/g' ) echo "tell app \"tls.cgi\" to do script \"$htscript\"" \ | osascript | perl -pe 's/\r/\n/g'


(tls.cgi is the name of the standalone stack.)

And now I can ssh into the server and do things like this:

% tls return number of cds in bg 1


% tls >recipes.txt
put "" into reports
repeat with i = 1 to number of cds in bg "Recipes"
  put (bg fld "Title" of cd i) & return after reports
end repeat
return reports


% tls 'return somethingOrOther()' | grep ...


HyperCard is dead! Long live HyperCard!

(Next up: remote script editing using BBEdit!?)