Help executing o.s commands from JAVA
Date: 1997/03/19
Message-ID: <3330438C.6F6F_at_bigfoot.com>#1/1
This is a multi-part message in MIME format.
--------------6F7F93A37D2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit
Hi there !
I am trying to execute some O.S. commands from JAVA program.
Here is my requirement ....
I am workin on WinNT 4.0; and have Oracle installed on my workstation.
>From command line I am able to export a particular database as
c:\orant\bin\exp72.exe user/passwd_at_db owner=usr
The same command I want to execute from a Java program; and I am having problems. When i run the attached program; it just waits forever.
Hope somebody has some answer/clue to my problem.
TIA.
Leo
leo_at_kronos.com
--------------6F7F93A37D2 Content-Type: text/plain; charset=us-ascii; name="RunCmd.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="RunCmd.java" //
// This class will launch the Windows CALC.EXE program //
import java.io.*;
public class RunCmd {
public static void main(String args[]) {
String cmnd = "command.com /c exp73.exe tkcsowner/tkcsowner_at_bto_sqa1 owner=tkcsowner file=x.dmp" + "\n";
try {
//Process p = Runtime.getRuntime().exec("cmd.exe /c exp73.exe tkcsowner/tkcsowner_at_bto_sqa1 owner=tkcsowner file=x.dmp");
Process p = Runtime.getRuntime().exec(cmnd);
// Process p = Runtime.getRuntime().exec("cmd.exe /c t.bat");
InputStream is = p.getInputStream();
int i;
while ((i=(is.read())) != -1) System.out.write(i);
}
catch (IOException e) {
System.out.println(e);
return;
}
}
}
--------------6F7F93A37D2-- Received on Wed Mar 19 1997 - 00:00:00 CET
