Solved

Sending data to a dos program

Posted on 2011-09-22
8
205 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

863 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

19 Experts available now in Live!

Get 1:1 Help Now