$! DECNET.COM - Execute commands on a remote node. $! $! Author: Peter Johansson (peter@cs.umbc.edu) $! $! This file is intended for informational purposes only - Execute it at $! your own risk. All code Copyright (C) 1993 by Peter Johansson. $! $! Non-commercial use unrestricted so long as all attributions remain $! intact. That is, if you use any part or parts of this code, I want $! credit for my work. $! $! --- begin origonal file --- $! $! Command file to execute commands on a remote DECnet node. $! $! Written by: Peter(@umbc2.bitnet) Johansson $! Last update: 12-Dec-87 $! $! Ideas and skeleton code from Kevin B. York's revision of Ed Guy's $! origonal REMOTE.COM program. (They had a good idea, but a lousy $! program. I fixed most (if not all) of the bugs, and generally $! streamlined the program.) $! $! p1 = node or node::account $! p2 .. p8 = command (if none then prompt for input) $! $ set noon $ on warning then goto error $ on control_y then goto bye $ say = "write sys$output" $ input = "read/end=bye/error=error sys$command" $ eot[0,32] = 4 ! ASCII EOT (End Of Transmission) = CTL/D $ task = "pjremobj" $ nofile = 0 $ interactive = "T" $! $ start: $ if p1 .nes. "" then goto good_node $ input p1 /prompt="Node [::Username] " $ goto start $ good_node: $ comp = f$element (0, ":" ,p1) !Get the NODE name. $ node = "''comp'::" !set displayable version. $ acnt = f$element (2, ":" ,p1) !Try for account name. $ if acnt .eqs. ":" then goto open_link !Did we get an account? $ set term/noecho !Yes...Get the password. $ input tmp /prompt="Password:" $ set term/echo $ say "" $ node = node + acnt !Displayable NODE name. $ comp = "''comp'""''acnt' ''tmp'""" !Functional NODE name. $! $ open_link: ! open connections to remote node $ open/read/write rem$file 'comp'::"task=''task'" $! $ if p2 .eqs. "" then goto kbd_inp !Use arguements as command? $ interactive = "F" $ p2 = f$edit("''p2' ''p3' ''p4' ''p5' ''p6' ''p7' ''p8'", "trim") $ goto parse $! $ kbd_inp: $ say "Signed in to account ''node'" $ say "Type CTL/Z for local menu." $ input = "read/end=menu/error=error sys$command" $ goto loop $! $ menu: $ type sys$input Local commands: 1) Return to network connection 2) Enter commands on local node 3) Attach to master process 4) Exit and close network link $ local_cmd_loop: $ input cmd /prompt="Choice (1-4) " $ cmd_num = f$integer (cmd) $ if (cmd_num .lt 1) .or. (cmd .gt. 4) then goto local_cmd_loop $ goto local_'cmd_num' $! $ local_2: $ say "Type CTL/Z to return to local menu." $ dcl_loop: $ input cmd /prompt="DCL> " !Command please? $ if cmd .eqs. "" then goto dcl_loop !get a command $ cmd = f$edit (cmd, "compress, trim") !clean up command $ set noon $ 'cmd' $ set on $ goto dcl_loop $! $ local_3: $ pid = f$getjpi ("", "pid") $ master_pid = f$getjpi ("", "master_pid") $ if pid .nes. master_pid then goto local_attach $ say "You are not running from a subprocess." $ goto menu $ local_attach: $ say "Use $ ATTACH ''f$process()' to return to network connection." $ attach/id='master_pid' $ goto menu $! $ local_1: $ loop: $ input p2 /prompt="''node'> " !Command please? $ if p2 .eqs. "" then goto loop !get a command $ p2 = f$edit (p2, "compress, trim") !clean up command $ parse: $ tmp = f$element (0, " ", p2) !Seperate command & arguement $ if tmp .nes. "." then goto parse_sym !bypass parsing? $ cmd = f$extract (2, f$length (p2), p2) $ goto do_cmd $ parse_sym: $ cmd = "'" + tmp + "'" !Try for GLOBAL SYMBOL subst. $ cmd := 'cmd $ if cmd .eqs. "" then cmd = tmp $ cmd = f$edit (cmd, "upcase") $ if (cmd .eqs. "EXIT") .or. (cmd .eqs. "LOGOUT") then goto menu $ i = 1 !Initalize arguement counter. $ parse_log: $ tmp = f$element (i, " ", p2) !Try for LOGICAL TRANS subst. $ if tmp .eqs. " " then goto do_cmd $ tmp1 = f$trnlnm (tmp) $ if tmp1 .eqs. "" then tmp1 = tmp $ cmd = cmd + " " + tmp1 $ i = i + 1 $ if i .lt. 9 then goto parse_log $! $ do_cmd: $ if interactive then say cmd !Display new command. $ write rem$file cmd !Execute new command. $ read: $ read/end=bye rem$file line !Get responce. $ if line .eqs. eot then goto got_eot $ say line !Display responce. $ goto read $ got_eot: !EOT marker $ if interactive then goto loop !Exit if immediate mode. $! $ local_4: $ bye: $ on warning then exit $ close rem$file !Close communications. $ if interactive then say "Network link closed." $ exit !See you in another deminsion. $! $ error: $ save_status = $status $! if error is ACP network, go to network error handling. $ if save_status .eq. 268550146 then goto network_error $ say "Error in DECnet.com. Contact PJ." $ goto bye $! $ network_error: $! a network error has occurred. Make one (1) attemt to create (or re-create) $! the object. If still error, say so and exit. $ nofile = nofile + 1 $ if nofile .lt. 2 then goto create_object !Attempt to create object. $ say "Network error. Can't continue..." $ goto bye $! $ create_object: $ say "Creating object on remote node ''node'" $ on warning then goto create_error $ create 'comp'::'task'.com $ deck $! $! PJ's Remote Object (12-Dec-87) $! $ remote: $ set noverify $ set noon $ on error then goto rembye $ eot[0,32] = 4 $ open/read/write net sys$net $ define sys$output net $ remlp: $ read/end=rembye net command $ set noon $ 'command' $ set on $ write sys$output eot $ goto remlp $ rembye: $ set noon $ close net $ stop/id=0 $ exit $eod $! $ say "Object created successfully." $ on warning then goto error ! reset error trapping $ goto open_link ! attempt to open the link again $! $ create_error: $ say "Unable to create remote object on ''node'" $ goto bye ! exit gracefully (close file)