Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to enter password on DOS prompt !

 
Anil Vupputuri
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jesse Tilly
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic