Solved

Sending data to a dos program

Posted on 2011-09-22
8
192 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
8 Comments
 
LVL 68

Accepted Solution

by:
Qlemo earned 250 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now