Hi,
I want to automate the telnet login in XP where in need the telnet session open in a different window. For this I am using "Process/ProcessBuilder" and then tried to write into the OutputStream of the telnet process. But I am not getting the desired result. Need your help.
The code looks like :
// cmd is " CMD.EXE /C start telnet <ip>" ProcessBuilder processBuilder = new ProcessBuilder(cmd); processBuilder.directory(new File(System.getenv("temp"))); processBuilder.redirectErrorStream(true); Process proc = processBuilder.start(); System.out.println("Trying to pass the telnet user ID for the login: promt.."); OutputStream out = proc.getOutputStream(); out.write("user\n".getBytes()); out.close(); System.out.println("Trying to pass the telnet password for the password: promt.."); OutputStream out = proc.getOutputStream(); out.write("pass\n".getBytes()); out.close(); //Some other command sequence....
The telnet session comes up then other data passed to the child process doesn't seem to have any apparent effect. It is required for me to remain the telenet window open.....
Any suggestion?