Open System Services Programmer's Guide
Example 51 Running an Interactive OSS Session From the Guardian Environment
== TACL macro for an interactive OSS session from the Guardian environment
== file: sh
== Start an OSSTTY process and OSS shell
?section sh routine
#push pname
[#case [#argument /value pname/ processname /syntax/
otherwise]
|1|
#set pname [#shiftstring /up/ [pname]]
[#case [#argument end
otherwise]
|1|
[#if [#processexists [pname]] |then|
#output Process [pname] already exists -- terminating.
#output
#pop pname
#return
] == end if
|otherwise|
#output Extraneous input -- terminating.
#output
#pop pname
#return
] == end case
|2|
#output Expecting a nonexistent process name -- terminating.
#output
#pop pname
#return
] == end case
#set pname [#shiftstring /down/ [pname]]
#chardel pname 1 for 1
[#push [pname]^in^buf [pname]^out^buf [pname]^prompt^buf [pname]^need^prompt
[pname]^status stdin stdout
] == end push
#set stdin /G/[pname]/#stdin
#set stdout /G/[pname]/#stdout
sink [#newprocess $system.system.osstty /name $[pname], nowait,
inv [pname]^in^buf dynamic, outv [pname]^out^buf/
-server]
sink [#newprocess $system.system.osh /status [pname]^status, nowait/
-p /bin/sh < [stdin] > [stdout] 2> [stdout]]
sink [#wait [pname]^out^buf]
#set [pname]^prompt^buf [#lineget [pname]^out^buf 1]
#set [pname]^need^prompt -1
#pop pname stdin stdout
== Remove previously defined OSSTTY/OSS shell environment
?section unsh routine
#frame
#push pname prog name
[#case [#argument /value pname/ processname /syntax/
otherwise]
|1|
#set pname [#shiftstring /up/ [pname]]
[#case [#argument end
otherwise]
|1|
|otherwise|
Using OSSTTY to Redirect Input and Output to Guardian Objects 223