Results 21 to 26 of 26
- 04-27-2012, 04:19 PM #21
Member
- Join Date
- Apr 2012
- Posts
- 12
- Rep Power
- 0
Re: How to send non-command data to the terminal from a JAVA program?
Here is my new code:
It has changed a bit since the beginning, but the problem is still the same.Java Code:final Process p = Runtime.getRuntime().exec("p4 login"); final BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); final char[] buf = new char[20]; System.out.println(new String(buf, 0, in.read(buf))); System.out.println("Sending password"); new PrintWriter(p.getOutputStream(),true).println(password); System.out.println("Password sent"); int read; while ((read = in.read(buf)) != -1) { System.out.print(new String(buf, 0, read)); System.out.flush(); if (read == 0) Thread.sleep(100); } loggedIn= false;
The program detects no data sent from the terminal to my program when the second request is sent.
- 04-27-2012, 04:25 PM #22
Re: How to send non-command data to the terminal from a JAVA program?
Where do you flush the data sent? Where is ending newline?
If you don't understand my response, don't ignore it, ask a question.
- 04-27-2012, 04:43 PM #23
Member
- Join Date
- Apr 2012
- Posts
- 12
- Rep Power
- 0
Re: How to send non-command data to the terminal from a JAVA program?
The data is flush with new PrintWriter(p.getOutputStream(),true).println(pass word);
the true parameter means automatic flush
The ending new line is automatic with the printlnLast edited by mtrompe; 04-27-2012 at 04:47 PM.
- 04-27-2012, 04:49 PM #24
Re: How to send non-command data to the terminal from a JAVA program?
Try reading and printing the error stream to see if there are any errors.
If you don't understand my response, don't ignore it, ask a question.
- 04-30-2012, 09:15 AM #25
Member
- Join Date
- Apr 2012
- Posts
- 12
- Rep Power
- 0
Re: How to send non-command data to the terminal from a JAVA program?
I tried printing the error stream, but nothing is printed, and the program seems to be stuck on the printing, as if blocked into a infinite loop
- 04-30-2012, 04:12 PM #26
Similar Threads
-
how to run the perl script on mac terminal using java program
By abhijitz in forum New To JavaReplies: 2Last Post: 04-10-2012, 11:58 AM -
To develop a program which will copy the data from database and send it via bluetooth
By adiotrox in forum New To JavaReplies: 3Last Post: 03-02-2012, 10:14 PM -
Is there any free SMS gateways to send SMS through java program or through jsp
By vivekjustthink in forum Advanced JavaReplies: 0Last Post: 06-24-2011, 02:22 PM -
send at command
By peiphb02 in forum CLDC and MIDPReplies: 0Last Post: 10-05-2009, 09:28 PM -
To send and recieve data stored in fileusing TCP program
By rosemary in forum NetworkingReplies: 2Last Post: 02-02-2009, 03:27 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks