wood burning stoves 2.0*
The moose likes Java in General and the fly likes How to enter password on DOS prompt ! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to enter password on DOS prompt !" Watch "How to enter password on DOS prompt !" New topic
Author

How to enter password on DOS prompt !

Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
Hi,
Can any one tell me ,how to enter password('*') on console and how to validate.How to handle Esc button to terminate the application on DOS prompt.
Thanks.
Anil.


SCJP 1.5, SCEA, ICED (287,484,486)
Jesse Tilly
Ranch Hand

Joined: Jun 25, 2000
Posts: 37
It can theoretically be done by manipulating the input and output streams associated with the program. However, DOS programs do not use STDIN and STDOUT in a standard fashion (ironic, eh?). Furthermore, exec'ing a program essentially forks it off. You can parse the output, but you cannot do much else. If someone has done this, I'd be interested to see it.
Without some form of JNI hook into running the process in a shell, you're out of luck. Sorry.
Jesse
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I did something similar to this, but not exactly the same. I used Runtime.exec("command.exe"). That starts a DOS session inside the JVM. This command also returns a Process object, which I then used to capture the input, output, and error streams from the new DOS session. Then I used those streams to send and recieve information to DOS. You could start your DOS application here, and you could send and recieve using the streams you got from your Process object. I only executed DOS commands and recieved their output, so I'm not exactly sure of the behavior of a DOS executable, but it would be worth a try. Let me know if you do this.
Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
Hai Bodie Minster,
Even if u get seperate process using
Runtime.exec("command.exe"),then how to key in password without using JNI concept.
Thanks.
Anil.
Savithri Devaraj
Ranch Hand

Joined: Jun 26, 2000
Posts: 103
Originally posted by Anil Vupputuri:
Hai Bodie Minster,
Even if u get seperate process using
Runtime.exec("command.exe"),then how to key in password without using JNI concept.
Thanks.
Anil.

If I understandd what you are saying, the application is a java application, right?
If it is a java application, you can provide command line parameters with any notation like -su userid, -sp password etc.,
and process them in your java program. Then the user has to call the application as:
java applicationName -su user1 -sp xyz
HTH,
Savithri
Nick Heudecker
Ranch Hand

Joined: Jul 09, 2000
Posts: 52
I recently had a similar problem with a CVS application and my only recourse was to implement the login portion of the CVS protocol. It was trivial to do, but didn't seem to be the most elegant solution.


---<br />Co-author of "Hibernate Quickly"<br /><a href="http://www.manning.com/books/peak" target="_blank" rel="nofollow">http://www.manning.com/books/peak</a>
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Once you have your process, you can send whatever you like using the streams from that process. But it sounds like you have considered that and decided that it won't work for you. I think I missed something. Can you help me to understand?
Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
Hi Bodie,
It seems u didn't understand the query, i need to enter password on DOS exclusively in astrik('*') format without JNI hook.when i used Runtime.exec("command.exe"),it starts DOS session not inside the JVM on win-NT.
-Anil
 
wood burning stoves
 
subject: How to enter password on DOS prompt !