Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sending data to a dos program

Posted on 2011-09-22
8
Medium Priority
?
234 Views
Last Modified: 2012-05-12
Hello everyone,

I have a program that runs lets call it testrunner, that excepts 2 parameters, databasename and userid.  So for example

testrunner -d test -u testuser

It then prompts for a password, there is no parameter for it in the command line.

I need to call testrunner from a service, but I'm not sure if there is a way to run it, and then send the keystrokes to type hte password in when it prompts for it.

Any idea's?

Thanks!

DJB
0
Comment
Question by:dbridle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 71

Accepted Solution

by:
Qlemo earned 1000 total points
ID: 36578948
You can try if
cmd /c echo password | testrunner -d test -u testuser
works. If not, you will have to use the VB Sendkey method, applied to the application/cmd window to send the key strokes required for the password, combined with some sleep time to allow for the password prompt.
0
 

Author Comment

by:dbridle
ID: 36578966
Thanks for your response, I will give the cmd /c command a shot,
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36579048
also if not there is a great free app called autoit which you can use to send keys, mouse clicks, wait for things to appear first etc.  yoou write this as a simple tect file script like batch file or vbscript and then it can compile it into an exe.

So you could have (pseudo copde)

run program testrunner etc.
Wait for window testrunner to appear
type in password
exit

the app would continue to run and accept other keystrokes if needed.  if you pipe the password in it will accept no real keystrokes

also as you compile it into an exe the password is not there in plain text

can help with links s syntax if needed... Once on pc but there are loads of example scripts with it when you download anyway.


Steve
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36582217
You can also try another approach using the Process class. Find example code on below link

http://stackoverflow.com/questions/6969731/get-output-into-my-application-from-another-java-console

The code only shows reading output from the console app but you can use the same principle of streams to write text as input to console app(e.g p.StandardInput.WriteLine("Password"))
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 36590485
Have you tried simple redirection as in the following?

   echo password | testrunner -d test -u testuser

or:

   echo password | (testrunner -d test -u testuser)


You could also try it without the spaces around the '|' (pipe symbol).
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 36590502
You might even prefer to get the password from a file. Suppose your password is stored in a text file named PASSWORD.TXT

You can then use the following:

   testrunner -d test -u testuser <password.txt

or:

   (testrunner -d test -u testuser) <passowrd.txt

0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36591922
I'm sure I hit submit on a comment like this last night, Paul I'm surprised you didn't suggest using ADS to hide the password like in your answer from before which I keep for my info here... I hadn't seen it used before BillDL and you mentioned it in this question and has come in handy on a number of occasions since -- no-one has worked out where the password comes from :-)

http://scripts.dragon-it.co.uk/links/batch-password1
( http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_25000620.html?cid=1133#a26130150 )

Steve
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 36592435
Ah, Steve (dragon-it), I never did reply to that thread.... I was playing about with ADS at the time and never finished my write-up on it as I digressed onto something else (as we do).

I've only got a few more things I want to accomplish in DOS at the moment and as they all involve embedded assembly code I've been dragging my heels for far too long now.... All will be revealed in the very near future.

I'm not sure whether the asker wanted to 'hide' the password from the user or whether he merely wanted a non-user assisted solution to logging into his program.

The solutions above only address the non-user assisted methods for getting a password into a program. They may not even work depending on whther the program flushes the keyboard buffer prior to fetching keystrokes (as you probably know quite well).

Sure, ADS, and even redirection can be used to hide a password from a casual user to some extent but i don't think that's the issue in this case. I could be wrong though.

:)


dbridle

Just so as you know what Steve is refering to, I wrote this comment (under the peened name t0t0) quite some time ago. It deals with hiding and retrieving a password using ADS:

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_25000620.html?cid=1133#a26130150
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question