From: boag@muvms3.bitnet (Bob Boag)
Newsgroups: comp.os.vms
Subject: Re: DecNet RPC and Xwindows
Date: 19 Aug 92 11:40:39 GMT
Organization: Marshall University

In article <1992Aug18.185340.12605@nap.amoco.com>, pgravel@nap.amoco.com (Philip L. Gravel) writes:
> In article <1247@esl.ESL.COM>, jsd@esl.com (Jeff Dalton) writes:
>  
>> I'm trying to start an Xwindows process running on a remote node and
>> have it displayed on my local node.  The catch is that I don't want to
>> log into the remote node to start the process.  I'm attempting to use
>> the DecNet Remote Command Execution facility, you know... the stuff that
>> looks like the following:
>> 
>>   type RMT_NODE::"username password":"task=FILE.COM"
> 
> On the remote node where I want the Xwindows client process to run, I have
> a command procedure named REM_DECTERM.COM which contains:
> 
> $       Set NoVerify
> $       Server_Node = F$TrnLNm("Sys$Rem_Node","LNm$Job") - "::"
> $       Client_Node = F$TrnLNm("Sys$Node","LNm$System")  - "::"
> $       Set Display /Create /Node='Server_Node'
> $       Create /Terminal=DECterm -
>         /NoProcess -
>         /Window_Attributes=( -
>          Title="''Client_Node' DECterm", -
>          Icon_Name="''Client_Node'" )
> $       Set Display /Delete
> $       Exit
> 
> Then on my local node, I enter:
> 
> $      TYPE client_node::"TASK=REM_DECTERM"
> 
> Of course, I have set up a symbol for this command.  Make sure all your
> DECnet proxies and Session Manager security authorizations are set up
> properly.
> 
> 
> Phil
> 
> -----
> Philip L. Gravel                      Internet: pgravel@nap.amoco.com
> Amoco Corporation, Chicago, IL        Phone:    (312)856-3553
> ----------
> These opinions aren't worth the paper they're written on and
> certainly don't reflect those of my employer.

I approached this in a similar fashion, but I wanted to be able to start
various decwindows applications from a remote system, not just DECterm.
Starting a DECterm was fine, but sometimes I wanted to be able to start
Bookreader, FileView, Calendar, Clock, etc. So, I wrote the following command
procedure which I use all of the time. It is called MU_REMOTE (MU stands for
Marshall University, just in case anyone is interested).

I order to use this procedure, you need to do the following things (to make
things easy, local node refers to your station and remote node refers to any
remote DECnet node you wish to have execute a command for use - such as
create/terminal, etc):

1. You must have proxy access on the remote node.

2. On your local node, you must use the Session Manager to Customize the
   Security to allow connections from the remote node.

3. Using either the Session Manager or FileView, create an application which
   will activate the MU_REMOTE procedure and specify the node name and command
   to perform. For example, if you wish to have a DECterm sent to you from a
   node named MYVAX1, you could define the application command as:

   @mu_remote myvax1 "create/terminal=decterm/detached/window=(icon:myvax1)"

Note that this procedure expects to find either a DECnet object called
MU_REMOTE or a file called MU_REMOTE.COM in your login directory on any remote
system you are using. Defining a DECnet object will allow you to use this
procedure on a system for access by many users without having a separate copy
in everyone's login directory.

Also note that this procedure does both the sending of the request from the
local system and the performing of the request on the remote system.

One final node, under FileView this procedure can ask for the remote system and
command to perform (by displaying dialog boxes) if you don't specify them as
paramters to the procedure, and it can display errors in pop-ups if necessary.
If you encounter problems, try looking for NETSERVER.LOG in your login
directory on the remote system - it may contain error messages which will
indicate why a command failed to work properly.

Here it is. (Sorry if this is an old version of VMS_SHARE - it is the only one
I could find handy.)

$! ------------------ CUT HERE -----------------------
$!
$! This archive created by VMS_SHARE Version 7.1-001  26-JUN-1989
$!   On 19-AUG-1992 11:05:48.20   By user BOAG 
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. MU_REMOTE.COM;10
$!
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ if f$getsyi("version") .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete/nolog 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete/nolog 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");
buff:=CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(buff))
;LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(buff));g:=0;LOOP EXITIF MARK(NONE)=END_OF(buff);x:=
ERASE_CHARACTER(1);IF g = 0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x=
"V" THEN APPEND_LINE;MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;
IF x="+" THEN g:=1;ERASE_LINE;ENDIF;ELSE IF x="-" THEN g:=0;ENDIF;ERASE_LINE;
ENDIF;ENDLOOP;p:="`";POSITION(BEGINNING_OF(buff));LOOP r:=SEARCH(p,FORWARD);
EXITIF r=0;POSITION(r);ERASE(r);COPY_TEXT(ASCII(INT(ERASE_CHARACTER(3))));
ENDLOOP;o:=GET_INFO(COMMAND_LINE,"output_file");WRITE_FILE(buff,o);
ENDPROCEDURE;Unpacker;EXIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create/nolog 'f'
X$ !
X$ !`009MU_REMOTE - Procedure for starting remote DECwindows applications
X$ !
X$ !`009This procedure performs both the sending of the request to a remote n
Vode
X$ !`009and servicing such a request from another node by examining the curre
Vnt
X$ !`009process mode. INTERACTIVE jobs are considered to be sending a remote
X$ !`009request to another node for an application and NETWORK jobs will serv
Vice
X$ !`009remote application requests.
X$ !
X$ !`009This procedure also assumes it is running under FILEVIEW if the OWNER
X$ !`009of this process is not null. Under FILEVIEW it will, if necessary,
X$ !`009display pop-up windows to request information and display status.
X$ !`009If the owner is null, for example it was run under the Session Manage
Vr,
X$ !`009the following parameters are used:
X$ !
X$ !`009P1 - remote node (creates a task-to-task communication to MU_REMOTE)
X$ !`009P2 - command to send to remote node
X$ !
X$ begin:
X$`009username = f$edit(f$getjpi(0,"username"),"trim")
X$`009if (username .eqs. "DECNET") then eoj
X$`009node = f$getsyi("nodename")
X$`009mode = f$getjpi(0,"mode")
X$`009if (mode .eqs. "INTERACTIVE") then goto interactive
X$`009if (mode .eqs. "NETWORK") then goto network
X$`009write sys$output "This procedure must run as an interactive job to"
X$`009write sys$output "request remote applications, or as a network job"
X$`009write sys$output "to service request. The current mode of ''mode'"
X$`009write sys$output "is not supported."
X$`009exit
X$
X$ interactive:
X$`009set noon
X$`009if (f$getjpi(0,"owner") .nes. "")
X$`009   then fileview = "true"
X$`009`009vue$suppress_output_popup
X$`009   else fileview = "false"
X$`009endif
X$
X$ i_get_node:
X$`009if ((p1 .eqs. "") .and. fileview)
X$`009   then vue$inquire_symbol "NODE Node:"
X$`009`009vue$read node
X$`009   else node = p1
X$`009endif
X$`009if (node .eqs. "")
X$`009   then if (fileview)
X$`009`009   then vue$popup_confirm "Node not specified. Try again?"
X$`009`009`009vue$read okay
X$`009`009`009if (okay .eqs. "NO") then exit
X$`009`009`009p1 = ""
X$`009`009`009goto i_get_node
X$`009`009   else goto i_finish
X$`009`009endif
X$`009endif
X$`009node = "''f$edit(node,"upcase")'"
X$
X$ i_get_command:
X$`009if ((p2 .eqs. "") .and. fileview)
X$`009   then vue$inquire_symbol "COMMAND Command:"
X$`009`009vue$read command
X$`009   else command = "''p2'"
X$`009endif
X$`009if (command .eqs. "")
X$`009   then if (fileview)
X$`009`009   then vue$popup_confirm "Command not specified. Try again?"
X$`009`009`009vue$read okay
X$`009`009`009if (okay .eqs. "NO") then exit
X$`009`009`009p2 = ""
X$`009`009`009goto i_get_command
X$`009`009   else goto i_finish
X$`009`009endif
X$`009endif
X$`009
X$`009if (fileview)
X$`009   then vue$popup_progress_box 20
X$`009`009vue$set_task_label "Connecting to ''node'"
X$`009endif
X$
X$ i_do_task:
X$`009if (f$trnlnm("DECW$DISPLAY") .nes. "")
X$`009   then define/user_mode sys$output nl:
X$`009`009show display/symbols
X$`009`009remote_node = decw$display_node`009! could be 0 too
X$`009   else remote_node = "0"
X$`009endif
X$`009if (remote_node .eqs. "0") then remote_node = f$trnlnm("sys$node")
X$`009node = node - "::"
X$`009task_name = "''node'::""task=mu_remote"""
X$`009open /write /error=i_no_connection link 'task_name'
X$`009write link "''remote_node'"
X$`009write link "''command'"
X$
X$ i_start_status:
X$`009read/end_of_file=i_failed_start/time_out=10 link status
X$`009if (status .nes. "START")
X$`009   then msg = f$fao("!AS NOT started on !AS!/!AS",command,node,status)
X$`009`009if (fileview)
X$`009`009   then vue$popup_message "''msg'"
X$`009`009endif
X$`009   else if (fileview)
X$`009`009   then vue$set_task_label "''node' ''command'"
X$`009`009`009wait 00:00:10.00
X$`009`009endif
X$`009endif
X$
X$ i_final_status:
X$`009read/end_of_file=i_failed_final/error=i_failed_final link status
X$
X$ i_display_final:
X$`009if (status .nes. "STOP")
X$`009   then msg = f$fao("!AS on !AS returned:!/!AS",command,node,status)
X$`009`009if (fileview)
X$`009`009   then vue$popup_message "''msg'"
X$`009`009endif
X$`009endif
X$`009close/nolog link
X$`009goto i_finish
X$
X$ i_finish:
X$`009exit
X$
X$ i_failed_start:
X$`009status = "Server did not respond with START status"
X$`009goto i_display_final
X$
X$ i_failed_final:
X$`009status = "Server did not respond with FINAL status"
X$`009goto i_display_final
X$
X$ i_no_connection:
X$`009message = f$message($status)
X$`009msg = f$fao("Connection to !AS failed, returned:!/!AS",node,message)
X$`009if (fileview) then vue$popup_message "''msg'"
X$`009goto i_finish
X$
X$ network:
X$`009set noverify
X$`009on error then goto shutdown
X$`009open /read /write link sys$net
X$`009set noon
X$`009purge /keep=3 netserver.log
X$
X$ n_remote_node:
X$`009read /end_of_file=n_shutdown /error=n_shutdown link remote_node
X$`009if (remote_node .eqs. "") then remote_node = f$trnlnm("sys$rem_node")
X$`009remote_node = remote_node - "::" + "::"
X$
X$ n_get_command:
X$`009read /end_of_file=n_shutdown /error=n_shutdown link command
X$`009command = "''f$edit(command,"trim,uncomment")'"
X$`009write link "START"
X$`009write sys$output "Starting: ''command'"
X$`009set noon
X$`009define /nolog sys$error sys$output
X$`009define decw$display 'remote_node'0.0
X$`009set display /create /node='remote_node'
X$`009on error then goto n_shutdown
X$
X$ n_perform_command:
X$`009set noon
X$`009''command'
X$`009status = $status
X$`009set on
X$
X$ n_return_status:
X$`009if (status)
X$`009   then write link "STOP"
X$`009   else write link "''f$message(status)'"
X$`009endif
X$
X$ n_shutdown:
X$`009set display /nopermanent
X$`009close/nolog link
X$`009eoj
$ CALL UNPACK MU_REMOTE.COM;10 756554368
$ EXIT
$! ------------------ CUT HERE -----------------------

-- 
Bob Boag                                BITNET:   boag@marshall
Senior Software Systems Analyst         Internet: boag@marshall.wvnet.edu
Marshall University Computer Center     Phone:    (304)696-2624
Huntington, WV 25755-5320               FAX:      (304)696-3601