$! ********************************************************************** $! * AUTOSPAWN.COM * $! * Quickly spawn an "on-the-fly" command procedure. * $! * * $! * This procedure accepts commands from the user and builds a * $! * temporary command procedure (use CTRL/Z to stop entering * $! * commands). The command procedure is then spawned, allowing the * $! * user to continue with the main session. When the procedure * $! * completes, a broadcast notification is sent to the user. The * $! * output of the procedure is contained in file * $! * SYS$LOGIN:AUTOSPAWN.LOG, unless an output file is specified * $! * as P1. * $! * * $! * When entering commands at the > prompt, use CTRL/Z to finish * $! * and spawn the procedure, "EDIT" to edit the procedure with the * $! * TPU editor, or CTRL/Y to abort the procedure. There is no need * $! * to preceed DCL commands with a "$"; they are inserted * $! * automatically. * $! * To enter a line of input data to a command, preceed the data * $! * with "#". * $! * * $! * AutoSpawn automatically specifies SET VERIFY at the beginning * $! * of the procedure. If you do not wish command verification, * $! * enter SET NOVERIFY as the first command. * $! * * $! * The idea for this utility came from the public domain * $! * SPOON utility. * $! * * $! * 26-MAY-1994 RDJ Command Procedure Creation. * $! * * $! * 16-SEP-1999 RDJ Made various cleanup changes. * $! ********************************************************************** $ On Control_Y Then Goto Abort $! $ PID = F$GetJPI("","PID") $ DefOutputSpec = F$TrnLnm("SYS$LOGIN") + "AUTOSPAWN.LOG" $ Output_File = F$Parse(P1,DefOutputSpec,,"Device") + - F$Parse(P1,DefOutputSpec,,"Directory") + - F$Parse(P1,DefOutputSpec,,"Name") + - F$Parse(P1,DefOutputSpec,,"Type") $! Output_File = F$Edit(P1,"Trim,UpCase") $! If Output_File .EQS. "" Then Output_File = "SYS$LOGIN:AUTOSPAWN.LOG" $ Temp_Command_File = "SYS$SCRATCH:AUTOSPAWN_''PID'.COM" $ ! name of temp file to hold procedure $ Edit_Command = "EDIT" ! command to edit temp file $ Data_Command = "#" ! command to signal data input $ AS_Prompt = "> " ! AUTOSPAWN prompt $! $ Close/NoLog OutFile $ Open/Write OutFile 'Temp_Command_File' $ On Control_Y Then Goto Close_And_Abort $ Write OutFile "$ Set Verify" $ Write SYS$OUTPUT "Press [CTRL/Z] to end input, or ""''Edit_Command'"" to edit." $! $ Loop: $ Read/Error=Done/End_Of_File=Done/Prompt="''AS_Prompt'" SYS$COMMAND Line $ If F$Edit(Line,"Trim,UpCase") .EQS. Edit_Command Then Goto Edit_File $ If F$Extract(0,F$Length(Data_Command),Line) .EQS. Data_Command $ Then ! Input is data $ Write OutFile F$Extract(1,F$Length(Line)-1,Line) $ Else ! Input is DCL $ Write OutFile "$ ",Line $ EndIf $ Goto Loop $! $ Edit_File: $ Close OutFile $ On CONTROL_Y Then Goto Abort $ Define/User_Mode SYS$INPUT SYS$COMMAND $ Edit/Tpu 'Temp_Command_File' $ Goto Run_Command $! $ Done: $ Close OutFile $! $ Run_Command: $ Open/Append OutFile 'Temp_Command_File' $ Write OutFile "$ Delete/NoLog/NoConfirm 'F$Environment(""Procedure"")'" $ Close OutFile $ If F$Mode() .NES. "INTERACTIVE" $ Then $ Option = "NO" $ Else $ Option = "" $ EndIf $ Spawn/NoWait/'Option'Notify/Input=NL:/Log/Output='Output_File' - @'Temp_Command_File' $ Write SYS$OUTPUT "Output will be located in ''Output_File'" $ Exit $! $ Close_And_Abort: $ Close OutFile $! $ Abort: $ If F$Search(Temp_Command_File) .NES. "" Then - Delete/NoLog/NoConfirm 'Temp_Command_File';* $ Write SYS$OUTPUT "(aborted)" $ Exit