From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 16-DEC-1988 03:57
To:	MRGATE::"ARISIA::EVERHART"
Subj:	EXECUTE batch utility 1/2


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Tue, 13 DEC 88 11:54:12 PDT
Received: from XX.LCS.MIT.EDU by KL.SRI.COM with TCP; Tue, 13 Dec 88 11:35:13 PST
Received: from PFC-VAX.MIT.EDU by XX.LCS.MIT.EDU via Chaosnet; 13 Dec 88 14:11-EST
Date: 13 Dec 88 14:12:50 EST
From: MRL%PFC-VAX.MIT.EDU@XX.LCS.MIT.EDU
To: INFO-VAX@KL.SRI.COM@XX
Subject: EXECUTE batch utility 1/2

$! ...................... Cut between dotted lines and save. .....................
$!.............................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.03 20-Oct-1988.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user MRL
$! on 13-DEC-1988 14:07:44.89.
$!
$! ATTENTION: To keep each article below 31 blocks (15872 bytes), this
$!            program has been transmitted in 2 parts.  You should
$!            concatenate ALL parts to ONE file and execute (@) that file.
$!
$! It contains the following 11 files:
$!        AAAREADME.TXT
$!        EXECUTECLD.CLD
$!        EXECUTE.COM
$!        EXECUTE_BUILD.COM
$!        EXECUTE_SYLOGIN.COM
$!        DESCR.C
$!        EDIT.C
$!        EXECUTE.C
$!        INPUT.C
$!        ITMLST.C
$!        SUBMIT.C
$!
$!==============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.03 20-Oct-1988 requires VMS V4.4 or higher."
$ EXIT 44 
$VERSION_OK:
$ GOTO START
$
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY

b_part := CREATE_BUFFER( "{Part}", GET_INFO( COMMAND_LINE, "file_name" ) );
s_file_spec := GET_INFO( COMMAND_LINE, "output_file" );SET( OUTPUT_FILE
, b_part, s_file_spec ); 
b_errors := CREATE_BUFFER( "{Errors}" );i_errors := 0; 
pat_beg_1 := ANCHOR & "-+-+-+ Beginning";
pat_beg_2 := LINE_BEGIN & "+-+-+-+ Beginning";
pat_end := ANCHOR & "+-+-+-+-+ End";
pat_trail := " " & LINE_END;POSITION( BEGINNING_OF( b_part ) ); LOOP b 
:= SEARCH( pat_trail, FORWARD); EXITIF b=0; POSITION( END_OF( b ) )
; LOOP MOVE_HORIZONTAL( -1 ); EXITIF CURRENT_CHARACTER <> ' '; ERASE_CHARACTER
( 1 ); EXITIF CURRENT_OFFSET=0; ENDLOOP; ENDLOOP; POSITION( BEGINNING_OF
( b_part ) ); i_append_line := 0; LOOP EXITIF MARK( NONE ) = END_OF( b_part )
; s_x := ERASE_CHARACTER( 1 ); 
  IF s_x = "+" THEN r_skip := SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip <
> 0 THEN 
      s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF; ENDIF; 
  IF s_x = "-" THEN r_skip := SEARCH( pat_end, FORWARD, EXACT ); IF r_skip <
> 0 THEN 
      s_x := ""; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip := MARK( NONE )
; r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip <> 0 THEN POSITION
( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET ); MOVE_VERTICAL( 1 )
; MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part ) ); ENDIF; ERASE
( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF; 
  IF s_x = "V" THEN 
    s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL
( -CURRENT_OFFSET ); ENDIF; i_append_line := 1; MOVE_VERTICAL( 1 ); ENDIF; 
  IF s_x = "X" THEN 
    s_x := ""; IF i_append_line <> 0 THEN APPEND_LINE; MOVE_HORIZONTAL
( -CURRENT_OFFSET ); ENDIF; i_append_line := 0; MOVE_VERTICAL( 1 ); ENDIF; 
  IF s_x <> "" THEN i_errors := i_errors + 1; s_text := CURRENT_LINE; POSITION
( b_errors ); 
    COPY_TEXT( "The following line could not be unpacked properly:" )
; SPLIT_LINE; COPY_TEXT( s_x ); COPY_TEXT( s_text ); POSITION( b_part )
; MOVE_VERTICAL( 1 ); ENDIF; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP 
  r_x := SEARCH( "`", FORWARD, EXACT ); EXITIF r_x = 0; POSITION( r_x )
; ERASE_CHARACTER( 1 ); 
  IF CURRENT_CHARACTER = "`" THEN MOVE_HORIZONTAL( 1 ); ELSE COPY_TEXT( ASCII
( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDIF; ENDLOOP; IF i_errors = 0 THEN SET
( NO_WRITE, b_errors, ON ); ELSE POSITION( BEGINNING_OF( b_errors ) ); 
  COPY_TEXT( FAO( "The following !UL errors were detected while unpacking !AS"
, i_errors, s_file_spec ) ); SPLIT_LINE; 
  SET( OUTPUT_FILE, b_errors, "SYS$COMMAND" );ENDIF; EXIT; 
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!,passed." )
$ RETURN
$
$START:
$ FILE_IS = "AAAREADME.TXT"
$ CHECKSUM_IS = 242160026
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
XThe EXECUTE.C utility was written by MRL%PFC-VAX.MIT.EDU@XX.LCS.MIT.EDU.
XIf you have any questions/suggestions, I would be glad to hear them.
XNOTE:  At our site, we set up SYS$BATCH as a low priority queue, and have
Xcreated SYS$BATCHI as a high priority queue.  EXECUTE will submit the job
Xin the high priority queue by selecting /HIGH.  If you have such a scheme,
Xbut with a queue of different name, modify EXECUTE_CLD.CLD.
$ GOSUB UNPACK_FILE
$ FILE_IS = "EXECUTECLD.CLD"
$ CHECKSUM_IS = 2014345111
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X`009MODULE EXECUTE_MAINCOMMANDS
X`009DEFINE VERB EXECUTE
X`009`009PARAMETER P1, LABEL=COMMAND, VALUE(TYPE=$REST_OF_LINE)
X`009`009QUALIFIER AFTER,VALUE(REQUIRED,TYPE=$DATETIME)
X`009`009QUALIFIER BATCH,DEFAULT
X`009`009QUALIFIER EDIT
X`009`009QUALIFIER HIGH,SYNTAX=HIGH_BATCH
X`009`009QUALIFIER LOG,VALUE(TYPE=$FILE,DEFAULT=EXECUTE.LOG),DEFAULT
X`009`009QUALIFIER QUEUE,VALUE(DEFAULT=SYS$BATCH),DEFAULT
X`009`009DISALLOW (COMMAND AND EDIT) OR (HIGH AND QUEUE)
X`009DEFINE SYNTAX HIGH_BATCH
X`009`009PARAMETER P1, LABEL=COMMAND, VALUE(TYPE=$REST_OF_LINE)
X`009`009QUALIFIER AFTER,VALUE(REQUIRED,TYPE=$DATETIME)
X`009`009QUALIFIER BATCH,DEFAULT
X`009`009QUALIFIER EDIT
X`009`009QUALIFIER LOG,VALUE(TYPE=$FILE,DEFAULT=EXECUTE.LOG),DEFAULT
X`009`009QUALIFIER QUEUE,VALUE(DEFAULT=SYS$BATCHI),DEFAULT
$ GOSUB UNPACK_FILE
$ FILE_IS = "EXECUTE.COM"
$ CHECKSUM_IS = 1531995459
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ set default sys$pfcroot:[iml.execute]
X@LIBD$:[MRL.SAVE]VMS_SHARE *.TXT;,*.CLD;,*.COM;,*.C; EXECUTE.SHARE  `032
$ GOSUB UNPACK_FILE
$ FILE_IS = "EXECUTE_BUILD.COM"
$ CHECKSUM_IS = 1728774750
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ CC DESCR
X$ CC EDIT
X$ CC EXECUTE
X$ CC INPUT
X$ CC ITMLST
X$ CC SUBMIT
X$ SET COMMAND EXECUTECLD/OBJ
X$ LINK EXECUTE,INPUT,DESCR,EXECUTECLD,SUBMIT,EDIT,ITMLST,SYS$INPUT/OPT
XSYS$SHARE:VAXCRTL/SHARE
$ GOSUB UNPACK_FILE
$ FILE_IS = "EXECUTE_SYLOGIN.COM"
$ CHECKSUM_IS = 1466317673
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ EXE*CUTE`009:== $EXECUTE
X$ EXL*OG`009:== "TYPE EXECUTE.LOG"`032
$ GOSUB UNPACK_FILE
$ FILE_IS = "DESCR.C"
$ CHECKSUM_IS = 1495362697
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X/* mkdesc
X *
X *`009Create a VMS call-by-reference string descriptor
X *
X */
X#include <descrip.h>
X
Xstruct dsc$descriptor * p;
X
Xstruct dsc$descriptor *descr (string)
Xchar *string;
X`123
X  p = (struct dsc$descriptor *) malloc (sizeof (struct dsc$descriptor));
X  p -> dsc$w_length = (short) strlen (string);
X  p -> dsc$b_dtype = DSC$K_DTYPE_T;
X  p -> dsc$b_class = DSC$K_CLASS_S;
X  p -> dsc$a_pointer = string;
X  return p;
X`125
X
Xfree_descr()
X`123
X  cfree (p);
X`125
$ GOSUB UNPACK_FILE
$ FILE_IS = "EDIT.C"
$ CHECKSUM_IS = 638279124
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X#include lnmdef
X
Xstruct ITEM_LIST `123
X`009short buffer_length ;
X`009short item_code ;
X`009char  *buffer_address ;
X`009short *return_length_address ;
X`009`125 ;
X
Xedit()
X`123
X`009char mail_edit[81],cmd_edit[81]="$@";
X`009int mail_edit_len, ier;
X
X`009struct ITEM_LIST itmlst[3] = `123`032
X`009`009`123 80, LNM$_STRING, mail_edit, 0`125,
X`009`009`123 4, LNM$_LENGTH, &mail_edit_len, 0`125,
X`009`009`123 0, 0, 0, 0`125 `125 ;
X
X`009ier = sys$trnlnm(0,descr("LNM$FILE_DEV"),descr("MAIL$EDIT"),
X`009`0090,&itmlst);
X`009if (!(ier&1)) `123
X`009`009strcpy(&mail_edit,"SYS$SYSTEM:MAILEDIT");
X`009`009mail_edit_len = strlen(mail_edit);
X`009`125
X
X`009if (strncmp("CALLABLE_",mail_edit,9) != 0) `123
X`009`009strncpy(&cmd_edit+2,mail_edit,mail_edit_len);
X`009`009mail_edit[mail_edit_len+1] = " ";
X`009`009strcpy(&cmd_edit+2+mail_edit_len," \"\" EXECUTE.COM");
X`009`009lib$spawn(descr(&cmd_edit));
X`009`125 else if (strncmp(&mail_edit+9,"EDT",3) == 0)
X`009   edt$edit(descr("execute.com"),descr("execute.com"));
X`009else if (strncmp(&mail_edit+9,"TPU",3) == 0)
X`009   tpu$edit(descr("execute.com"),descr("execute.com"));
X`125
$ GOSUB UNPACK_FILE
$ FILE_IS = "EXECUTE.C"
$ CHECKSUM_IS = 2047739317
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X#include stdio
X#include descrip
X#include climsgdef
X
Xmain()
X`123
X`009int ilen = 0, ier, after_time[2], jobnum;
X`009char input[256],filename[81]="EXECUTE.COM",logfile[81];
X`009$DESCRIPTOR(inline,input);
X`009$DESCRIPTOR(logname,logfile);
X`009FILE *comfile_ptr;
X
X`009int lib$get_input(),execute_maincommands();
X
X/* Get input specified in command. */
X
X`009ier = lib$get_foreign(&inline,0,&ilen,0);
X
X`009ier = strncpy(&input[8],&input[0],ilen);
X`009ier = strncpy(&input[0],"execute ",8);
X
X`009ier = cli$dcl_parse(&inline,execute_maincommands,lib$get_input);
X`009if (!(ier&1)) exit();
X
X`009assign_terminal();
X
X`009comfile_ptr = fopen("EXECUTE.COM","w");
X`009if (cli$present(descr("BATCH")) == CLI$_NEGATED) `123
X`009`009fputs("$ on error then goto exit\n",comfile_ptr);
X`009`009fputs("$ on warning then goto exit\n",comfile_ptr);
X`009`009fputs("$ verify = f$verify(0)\n",comfile_ptr);
X`009`009fputs("$ set ver\n",comfile_ptr);
X`009`125
X
X`009if (cli$present(descr("EDIT"))&1) `123
X`009`009fgetname(comfile_ptr,&filename);
X`009`009fprintf (comfile_ptr,"$ set default %s\n",getenv("PATH"));
X`009`009fclose(comfile_ptr);
X`009`009edit();
X`009`009delete (&filename);
X`009`009filename[strcspn(&filename,";")] = 0;
X`009`009ier = cli$dcl_parse(&inline,execute_maincommands,lib$get_input);
X`009`125 else `123
X`009`009fgetname(comfile_ptr,&filename);
X`009`009if (cli$present(descr("BATCH")) != CLI$_NEGATED)
X`009`009        fprintf (comfile_ptr,"$ set default %s\n",
X`009`009`009`009`009`009`009getenv("PATH"));
X`009`009if (cli$get_value(descr("COMMAND"),&inline)&1) `123
X`009`009`009input[ilen] = 0;
X`009`009`009fprintf(comfile_ptr,"%s\n",&input);
X`009`009`125
X`009`009else while (ilen >= 0) `123
X`009`009`009get_input_prompt(&input,&255,&ilen,descr("EXECUTE> "));
X`009`009`009if (ilen >= 0) fprintf(comfile_ptr,"%s\n",&input);
X`009`009`125
X`009`009if (cli$present(descr("BATCH")) == CLI$_NEGATED) `123
X`009`009`009fputs("$ exit:\n",comfile_ptr);
X`009`009`009fputs("$ verify = f$verify(verify)\n",comfile_ptr);
X`009`009`009strcpy(&input,"$ delete ");
X`009`009`009strcat(&input,getenv("PATH"));
X`009`009`009strcat(&input,"execute.com;\n");
X`009`009`009fputs(&input,comfile_ptr);
X`009`009`125
X`009`009fclose(comfile_ptr);
X`009`009if (ilen == -1) `123`009`009/* CTRL-C entered. */
X`009`009`009delete (&filename);
X`009`009`009exit();
X`009`009`125
X`009`125
X
X`009if (cli$present(descr("BATCH"))&1) `123
X`009`009ilen = 0;
X`009`009if (cli$present(descr("AFTER"))&1) `123
X`009`009`009cli$get_value(descr("AFTER"),&inline,&ilen);
X`009`009`009inline.dsc$w_length = ilen;
X`009`009`009ier = sys$bintim(&inline,&after_time);
X`009`009`125
X`009`009cli$get_value(descr("LOG"),&logname,&ilen);
X`009`009logfile[ilen] = 0;
X`009`009cli$get_value(descr("QUEUE"),&inline,&ilen);
X`009`009input[ilen] = 0;
X`009`009ier = submit(filename,input,cli$present(descr("AFTER")),
X`009`009`009after_time,logfile,&jobnum);
X`009`009if (ier&1)
X`009`009`009printf("Job EXECUTE entry %d submitted to queue %s",
X`009`009`009`009jobnum,&input);
X`009`009else
X`009`009`009exit(ier);
X`009`125 else `123
X`009`009if (cli$present(descr("BATCH")) == CLI$_NEGATED &
X`009`009`009(cli$present(descr("EDIT"))&1) ) `123
X`009`009`009comfile_ptr = fopen("EXECUTE.COM","a");
X`009`009`009fputs("$ exit:\n",comfile_ptr);
X`009`009`009fputs("$ verify = f$verify(verify)\n",comfile_ptr);
X`009`009`009fclose(comfile_ptr);
X`009`009`125
X`009`009lib$do_command(descr("$@execute"));
X`009`125
X`125
$ GOSUB UNPACK_FILE
$ FILE_IS = "INPUT.C"
$ CHECKSUM_IS = 1293419609
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X#include descrip
X#include smgdef
X#include iodef
X
Xint flag;
Xint term_chan;
Xint keyboard_id,key_table_id;
Xint *variable_input;
X
X/*
X *  SUBROUTINE GET_INPUT_PROMPT
X *
X *  FUNCTION:
X *`009Gets line of input from terminal.
X *
X *  OUTPUTS:
X *`009LEN_INPUT  -  Length of input line.  If = -1, CTRLC entered.
X *`009`009      if = -2, CTRLZ entered.
X *
X *  NOTES:
X *`009Also, on first call, set LEN_INPUT to 1+LENGTH OF INPUT CHARCTER
X *`009for initializing the CTRLC AST.
X */
X
Xget_input_prompt(input,limit,len_input,prompt)
Xchar *input,*prompt;
Xint *len_input,*limit;
X`123
X`009int ier;
X
X `009ier = smg$read_composed_line(&keyboard_id,&key_table_id,
V     &`009`009*variable_input,prompt);`009/* Get line from terminal with prompt
X */
X
X`009if (!(ier&1) & ier != SMG$_EOF) exit(ier);
X
X`009if (flag == 0) `123`009`009`009/* If no CTRL-C has occurred */
X`009   if (ier != SMG$_EOF)`009`123`009`009/* End of input? */
X`009      str$trim(variable_input,variable_input,len_input);
X`009      *len_input = *len_input < *limit ?  *len_input : *limit;
X`009      strncpy(input,*(variable_input+1),*len_input);
X`009      input[*len_input] = 0;
X`009`009/* No. Get length of line and make sure it is not too long*/
X`009   `125 else
X`009      *len_input = -2;`009`009`009/* If CTRL-Z, say so */
X`009`125 else
X`009   *len_input = -1;`009`009`009/* If CTRL-C, say so */
X`125
X
Xctrlc_routine()`009`009`009`009/* CTRL-C AST routine */
X`123
X`009flag = 1;`009`009`009`009/* to set flag */
X`125
X
X
Xdeclare_ctrlc_ast()
X
X/*
X *  SUBROUTINE DECLARE_CTRLC_AST
X *
X *  FUNCTION:
X *`009Declares a CTRLC ast.
X */
X`123
X`009flag = 0;`009`009`009`009/* Init CTRL-C flag */
X`009sys$qiow(0,term_chan,IO$_SETMODE`124IO$M_CTRLCAST,0,0,0,
X     &`009      ctrlc_routine,0,0,0,0,0);`009`009/* Enable the AST */
X
X`125
X
Xstruct dsc$descriptor_d *p;
X
Xstruct dsc$descriptor_d *descr_dynamic()
X`123
X  p = (struct dsc$descriptor_d *) malloc (sizeof (struct dsc$descriptor_d));
X  p -> dsc$w_length = 0;
X  p -> dsc$b_dtype = 0;
X  p -> dsc$b_class = DSC$K_CLASS_D;
X  p -> dsc$a_pointer = 0;
X  return p;
X`125
X
Xassign_terminal()
X
X`123
X`009sys$assign(descr("tt"),&term_chan,0,0);`009/* Assign terminal */
X
X`009declare_ctrlc_ast();
X
X`009smg$create_virtual_keyboard(&keyboard_id,0,0,0,&20);
X
X`009smg$set_keypad_mode(&keyboard_id,&0);
X
X`009smg$create_key_table (&key_table_id);
X
X`009variable_input = descr_dynamic();
X`125
$ GOSUB UNPACK_FILE
$ FILE_IS = "ITMLST.C"
$ CHECKSUM_IS = 307460298
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X/*
X  ITMLST.C
X
X  FUNCTION:
X`009A set of routines to easily create item lists.  It allows one
X  to easily create item lists without the need for declaring arrays
X  or itemlist size.  Thus, the code can be easily changed to add or
X  delete item list codes.
X
X  Here is an example of how to use the routines (prints file to a queue):
X
X`009INIT_ITMLST`009/* Initialize item list
-+-+-+-+-+ End of part 1 +-+-+-+-+-

