0

Hello,

I want to create java application which can run .cmd file. I already write the code which run .cmd file, but my problem is the following:
this .cmd file prompts the user to enter his mail and password & I want my program to give these values to the .cmd file & don't take them from user. Is it possible?
the code as the following:

String[] command =
                {
                    "cmd",
                };
                Process p;
                try {
                    p = Runtime.getRuntime().exec(command);
                    new Thread(new SyncPipe(p.getErrorStream(), System.err)).start();
                    new Thread(new SyncPipe(p.getInputStream(), System.out)).start();
                    PrintWriter stdin = new PrintWriter(p.getOutputStream());
                    stdin.println("appcfg.cmd --no_cookies update ..\\HelloGAE\\war");
                    stdin.println("ehossny@xxx.com");// email

                    stdin.println("xxxx");       //password
                    stdin.flush();
                    // write any other commands you want here
                    stdin.close();
                    int returnCode;
                    returnCode = p.waitFor();
                    System.out.println("Return code = " + returnCode);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
2
Contributors
8
Replies
27
Views
4 Years
Discussion Span
Last Post by emanhossnycs
0

yes, I try to supply the mail and passwod through stdin, but it takes the mail and then through null pointer exception and didn't take password--> I don't know why it reads the mail and didn't read the password??

0

actually the o/p which appears to me is as the following:

Email: Password for ehossny@xxx.com: 
java.lang.NullPointerException
Unable to update app: null

this means that stdin reads the email & didn't read the password. I don't know why. So I didn't mention this in my first mail bcos the null pointer exception appears in the o/p & I asked if anyone have a solution to this problem & ignoring my o/p.

0

I wonder if maybe it's not doing a simple standard read from sysin for the password, ie a special read that doesn't display the input characters?

0

it may that ur suggestion is true. but how we can do this and make it reads the pass?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.