views:

131

answers:

2

I'm using Delphi 2010, and I need to run a console application and automate the tasks that would normally require the user to enter information (for example a password).

So basically I need some way to pipe all the text and read the lines so I know when the application is read for some kind of input, then automatically have my program send the text that the other application needs.

The program I was trying to automate is a Cygwin port of OpenSSH, and I need to enter the password (which isn't displayed when typed) and then press enter.

+1  A: 

You can try and get this library uZpRunConsoleApp.pas which contains a really nice class to work with console apps. It will also do what you want it to do, send and receive from a console app to your application.

Aldo
That library is just returning gibberish for me...
Nowayz
I had to change one of the functions to return a PChar rather than an PAnsiChar but when I get the text that I've read it's all Chinese looking...
Nowayz
This library is obviously written for a very early version of Delphi which code isn't compatible with 2010 at all, thus making it so this code doesn't work without many changes which I apparently aren't making correctly.
Nowayz
A: 

you can send char by message to the Console window , there is an example : Send To Console

note : it is`t exactly about your question , I made it for other purposes but it will be useful for you ...

good luck ...

Mahmood_N