Page 2 of 2 FirstFirst 12
Results 21 to 26 of 26
  1. #21
    mtrompe is offline Member
    Join Date
    Apr 2012
    Posts
    12
    Rep Power
    0

    Default Re: How to send non-command data to the terminal from a JAVA program?

    Here is my new code:

    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;
    It has changed a bit since the beginning, but the problem is still the same.

    The program detects no data sent from the terminal to my program when the second request is sent.

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default 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.

  3. #23
    mtrompe is offline Member
    Join Date
    Apr 2012
    Posts
    12
    Rep Power
    0

    Default 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 println
    Last edited by mtrompe; 04-27-2012 at 04:47 PM.

  4. #24
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default 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.

  5. #25
    mtrompe is offline Member
    Join Date
    Apr 2012
    Posts
    12
    Rep Power
    0

    Default 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

  6. #26
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: How to send non-command data to the terminal from a JAVA program?

    What does it print in the loop?
    If you don't understand my response, don't ignore it, ask a question.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 2
    Last Post: 04-10-2012, 11:58 AM
  2. Replies: 3
    Last Post: 03-02-2012, 10:14 PM
  3. Replies: 0
    Last Post: 06-24-2011, 02:22 PM
  4. send at command
    By peiphb02 in forum CLDC and MIDP
    Replies: 0
    Last Post: 10-05-2009, 09:28 PM
  5. Replies: 2
    Last Post: 02-02-2009, 03:27 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •