|
Re: help needed for using Runtime.getRuntime().exec
|
Posted: Jun 21, 2005 1:12 AM
|
|
Hi , I checked with the code u have provided.But Again the same thing repeats.It opens a new console for telnet and it asks for the login id. Is there any way to capture the content of this new screen?Iam pasting my code here .Please have a look at it:- import java.io.*;
public class Sample2 { public static void main(String arg[]) { try { Runtime r=Runtime.getRuntime(); String[] cmd={"cmd.exe" , "/c" , "start" ,"d:/run.bat"}; Process P=r.exec(cmd); BufferedReader br=new BufferedReader(new InputStreamReader(P.getInputStream())); String str=br.readLine(); System.out.println(str); while(str!=null) { System.out.println(str); str=br.readLine(); } } catch(IOException ioe) { ioe.printStackTrace(); System.exit(0); } } }
My Run.bat contains only one statement:- telnet <servername>
-------------------------
to implement the code u have provided , I created 3 variables servername,username,password in thye program and modified the cmd variable as:- String[] cmd={"cmd.exe" , "/c" , "start" ,"d:/run.bat","o "+servername,username,password}; This also gives the same result.
what does this "o "+servername for ? Is there ant tutorial like stuff to know what options(parameters) I can use in this exec();function..
Thanks Sujeevan
|
|