[OpenVMS, Java] Executing DCL commands started by Java
PRODUCT: J2SE(TM) Development Kit (JDK) 6.0-1 HP IA64VMS GNV Version 2.1-3
OP/SYS: OpenVMS IA64 Version 8.3-1H1
COMPONENT: Runtime.getRuntime().exec()
SOURCE: Philippe Vouters Fontainebleau/France
HIGH QUALITY MOBILES+TABLETS: http://android-land.fr
OVERVIEW: This article does not contradict HP's mentionned restrictions in its Java OpenVMS User Guide on-line document. However it shows a possibility on how to execute, using pure Java, DCL commands such as DIRECTORY or SHOW LOGICAL and also how to execute DCL verbs such as MMS or DCL process global symbols. For this it uses an HP provided freeware named GNV which contains a DCL wrapper named DCL.EXE in GNU:[BIN]. All this is made transparent as VAXC$PATH that GNV setup defines as GNU:[BIN] is a logical considered by Java V6.0 for OpenVMS systems.
*** CAUTION *** This sample program has been tested using J2SE(TM) Development Kit (JDK) V6.0-1 and GNV Version 2.1-3 on OpenVMS IA64 Version 8.3-1H1. However, we cannot guarantee its effectiveness because of the possibility of error in transmitting or implementing it. It is meant to be used as a template for writing your own program, and may require modification for use on your system.
PROGRAM NOTES: Without VAXC$PATH defined to GNU:[BIN] and GNU:[BIN] not containing DCL.EXE the Java program in the PROGRAM section of this article does not work. Assigning VAXC$PATH to SYS$SYSTEM: causes the Java program to hang. Copying GNU:[BIN]DCL.EXE to your default directory and deassigning VAXC$PATH makes the program work as advertised. However under GNV bash issuing the command hereafter causes the following symptoms: $ bash bash$ sh -c 'dcl.exe ls cd/' %DCL-W-ACTIMAGE, error activating image SYS$COMMON:[SYSEXE]DCL.EXE - -CLI-E-IMGNAME, image file DSA0:[SYS71.SYSCOMMON.][SYSEXE]DCL.EXE - -SYSTEM-F-ACCVIO, access violation, reason mask=26, virtual address=000000007FFD 1160, PC=000000000000001A, PS=7FF93EA5 bash$ whereas a command analog to what is issued in the PROGRAM BUILD AND OUTPUT section of this document using Java V1.6.0 produces good results: bash$ sh -c '/gnu/bin/dcl.exe dire \*.java' Directory $1$DGA102:[PHV] IOStream.java;2 MyRTLTest.java;3 Testexec.java;5 Testexec2.java;8 Testexec2.java;7 Testexec2.java;6 Testexec2.java;5 Testexec2.java;4 Testexec2.java;3 Testexec2.java;2 Testexec2.java;1 VMS_SYSCalls.java;3 Total of 12 files. bash$
PROGRAM BUILD AND OUTPUT: $ javac Testexec2.java $ java "Testexec2" dcl.exe mms {TERM=vt100-80, HOME=$1$dga102:[phv], XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt , PATH=$1$dga102:[phv], NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat, USER=PHV} %MMS-F-NOACCESS, Unable to access file "DESCRIP.MMS". -RMS-E-FNF, file not found $ java "Testexec2" dcl.exe dire *.java {TERM=vt100-80, HOME=$1$dga102:[phv], XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt , PATH=$1$dga102:[phv], NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat, USER=PHV} Directory $1$DGA102:[PHV] IOStream.java;2 MyRTLTest.java;3 Testexec.java;5 Testexec2.java;8 Testexec2.java;7 Testexec2.java;6 Testexec2.java;5 Testexec2.java;4 Testexec2.java;3 Testexec2.java;2 Testexec2.java;1 VMS_SYSCalls.java;3 Total of 12 files. $ java "Testexec2" dcl.exe sho log perl* {TERM=vt100-80, HOME=$1$dga102:[phv], XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt , PATH=$1$dga102:[phv], NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat, USER=PHV} (LNM$PROCESS_TABLE) "PERLSHR" = "SYS$COMMON:[PERL5_8_6]perlshr.exe" (LNM$JOB_890550C0) (LNM$GROUP_022000) (LNM$SYSTEM_TABLE) "PERLSHR" = "PERL_ROOT:[000000]PERLSHR.EXE" "PERL_ROOT" = "DSA0:[SYS71.SYSCOMMON.PERL5_8_6.]" (LNM$SYSCLUSTER_TABLE) (DECW$LOGICAL_NAMES) $ java "Testexec2" dcl.exe ls cd/ {TERM=vt100-80, HOME=$1$dga102:[phv], XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt , PATH=$1$dga102:[phv], NLSPATH=/usr/dt/lib/nls/msg/%L/%N.cat, USER=PHV} CD.C CD.EXE CD.OBJ $ sho symbol/global ls LS == "$$1$DGA102:[PHV.LS]LS.EXE"
PROGRAM: // // Testexec2.java // // // Copyright (C) 2010 by Philippe.Vouters@laposte.net // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by the // Free Software Foundation, either version 3 of the License, or // any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // import java.io.*; import java.lang.*; public class Testexec2 { public static void main(String [] args) throws IOException, InterruptedException { Process pid; System.out.println(System.getenv()); if (args.length > 1){ try { String cmd = ""; for (int i=0 ; i < args.length ; i++){ cmd = cmd + args[i]; if (i < args.length -1) { cmd = cmd + " "; } } pid=Runtime.getRuntime().exec(cmd); BufferedReader input = new BufferedReader (new InputStreamReader(pid.getInputStream())); String line; while ((line = input.readLine()) != null) { System.out.println(line); } input.close(); pid.waitFor(); } catch (IllegalArgumentException e) { System.err.println("Don't know how to activate son"); System.exit(1); } } } }
RELATED DCL ARTICLES: ../tima/OpenVMS-GNV-Alternate_DCL_image_using_a_Telnet_device.html ../tima/OpenVMS-Java-Activating_DCL_procedure-Testing_GETENV_logical.html
REFERENCE(S): Chapter "Working with Runtime.exec()" of HP's Java V6.0 User Guide listing all the restrictions and avalaible at: http://h18012.www1.hp.com/java/documentation/1.6.0/ivms/docs/user_guide.html#workingwruntimeexec Simple Java Windows coding samples at: http://www.rgagnon.com/javadetails/java-0014.html