Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Runtime.exec( cmd ) on NT platform

0 views
Skip to first unread message

Deepak Gupta

unread,
Jun 26, 1998, 3:00:00 AM6/26/98
to

I'm trying to execute a DOS command on NT, using the Runtime.exec (
String command) method.

Here's the section of code that fails at runtime with a fatal exception.

// Check-in source file into PVCS.
String commandString2 = new String("put -u -t\"first
revison\" " + dirFileList[j]);

System.out.println ("PVCS command = " + commandString2
);

Runtime myRunTime2 = Runtime.getRuntime();
Process myProcess2 = null;

try
{
myProcess2 = myRunTime2.exec( commandString2 );
}
catch (IOException iox)
{
iox.printStackTrace();
}

// Wait for this process to complete.
try
{
myProcess2.waitFor();
}
catch (InterruptedException ie)
{
ie.printStackTrace();
}

At runtime I get :-

PVCS command = put -u -t"first revison" BigInteger.java
java.io.IOException: CreateProcess: put -u -t"first revison"
BigInteger.java error=2
at java.lang.Win32Process.<init>(Win32Process.java:59)
at java.lang.Runtime.exec(Runtime.java:175)
at java.lang.Runtime.exec(Runtime.java:137)
at CheckinTree.DescendTree(CheckinTree.java:162) <= this
line is where I try to invoke Runtime.exec(String).

Anyone know why I can't (as it appears) create a process ?

cheers,

Deepak Gupta

colar

unread,
Jun 26, 1998, 3:00:00 AM6/26/98
to

Deepak Gupta wrote:
>
> I'm trying to execute a DOS command on NT, using the Runtime.exec (
> String command) method.
>

try this

String executer(String cmd)

{

String erreurs="";

String erreur;

try

{

Process p =Runtime.getRuntime().exec(cmd);

DataInputStream dis=new DataInputStream(p.getErrorStream());

while ((erreur=dis.readLine()) != null) erreurs+=erreur+'\n';

p.waitFor() ;

}

catch(Exception ex) {erreurs="Impossible de lancer (le chemin de
l'application est sans doute faux)";}

return(erreurs);

}


--
Colar Thibaut
USTL France
co...@lifl.fr

0 new messages