Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Capturing output of a command line app

137 views
Skip to first unread message

Peter S.

unread,
Aug 16, 2004, 8:48:51 AM8/16/04
to
Hello all,

I want to capture the output of a command line application in real time and
not all together after the app has finished (e.g. c:\dir *.* /s > logfile
and then load the contents of logfile) . All the examples I found out use
CreateProcess but the output of the command line is loaded at the end.

Thank you very much


Peter S.

unread,
Aug 17, 2004, 9:20:59 AM8/17/04
to
Hello Ryan,

Yes if you please I would like the component you have. How can I get it?

"Ryan Mills" <rmcon...@mills-enterprise.ca> wrote in message
news:8pv3i0dhdtrg2dq6e...@4ax.com...
> If you are familiar with using pipes, then you can actually pipe the
output of
> the command line application back into your program. I believe I have a
> component available for this type of thing....if you want a copy of it?
>
> Ryan.

Peter Below (TeamB)

unread,
Aug 17, 2004, 11:59:43 AM8/17/04
to
Here are a couple of URLs, some of them may even be still valid:

TRedirector http://www.pana.com/robert/Dcomp.html
TGUI2Console www.delphipages.com in the 'NonVisual' section
code example: http://www.prel.btinternet.co.uk/downloads/console.zip
http://www.delphi3000.com/articles/article_2112.asp
http://www.torry.net/tasks.htm, look for DosCommand

--
Peter Below (TeamB)
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be


Peter S.

unread,
Aug 17, 2004, 6:18:17 PM8/17/04
to
Hello Peter,

I downloaded doscommand and I would like to try TRedirector as well, but the
link is dead. Any other place where I can download it?

Thank you

"Peter Below (TeamB)" <10011...@compuXXserve.com> wrote in message
news:VA.0000b1a...@nomail.please...

Peter Below (TeamB)

unread,
Aug 18, 2004, 6:20:19 AM8/18/04
to
In article <4122...@newsgroups.borland.com>, Peter S. wrote:
> I downloaded doscommand and I would like to try TRedirector as well, but the
> link is dead. Any other place where I can download it?

I don't have any other link. Search for it via Google.

Ryan Mills

unread,
Aug 18, 2004, 10:12:36 AM8/18/04
to
I've posted it to the attachments group for anyone who's interested.

Please note: I didn't write this, but I do use it. It does have it's problems
but I've never really found them to be show stoppers, just annoying.

HTH,
Ryan

Peter S.

unread,
Aug 18, 2004, 5:40:19 PM8/18/04
to
Thank you Ryan but I need your advice....

I have a TMemo in a form and a button. In the OnClick of the button I write
:

var t : TEcecutionLibrary;
cmd : string;
begin
t := TExecutionLibrary(memo1); // my tmemo
t.command := cmd
t.execute;
..........................
end;

How can I use the t.OnLineAvailable???

Thank you

"Ryan Mills" <rmcon...@mills-enterprise.ca> wrote in message

news:iro6i05hkgcc1j9b7...@4ax.com...

Jacques Oberto

unread,
Aug 19, 2004, 4:23:40 AM8/19/04
to

"Peter S." <pe...@hotmail.com> a écrit dans le message de
news:4122...@newsgroups.borland.com...

> Hello Peter,
>
> I downloaded doscommand and I would like to try TRedirector as well, but
the
> link is dead. Any other place where I can download it?
>
> Thank you
>

DosCommand worked better for my case than TRedirector.
However, the original doscommand version has an annoying
memory leak which would crash my app after 50,000 or more
calls. The corrected code can be found on the author's page
and is called doscommand_tk:
http://maxxdelphisite.free.fr/

Jacques


Jacques Oberto

unread,
Aug 19, 2004, 5:20:53 AM8/19/04
to

"Peter S." <pe...@hotmail.com> a écrit dans le message de
news:4124...@newsgroups.borland.com...
> Hello Oberto,
>
> The problem I am facing is that the results from the doscommand are not
> immediate but it seems that it collects in the buffer some data and
outputs
> them when buffer is filled. I do need to show the ouput of my dos programm
> immediately on a tmemo. This is why I want to try TRedirector
>

Hi Peter:

You might try the Doscommand.OnNewLine event instead of the OnTerminated.

Jacques


Peter S.

unread,
Aug 19, 2004, 6:36:00 AM8/19/04
to
Thats what I did!!!! When my dos programm runs it shows some infos about the
data it has read...these first lines appear in my memo after a few seconds
and not directly :o(. Do you know how to use TRiderector? an example maybe

Thank you

Ο "Jacques Oberto" <j...@nospam.com> έγραψε στο μήνυμα
news:4124...@newsgroups.borland.com...
>
> "Peter S." <pe...@hotmail.com> a ιcrit dans le message de

Jacques Oberto

unread,
Aug 19, 2004, 8:53:07 AM8/19/04
to

"Peter S." <pe...@hotmail.com> a écrit dans le message de
news:4124...@newsgroups.borland.com...

> Thats what I did!!!! When my dos programm runs it shows some infos about
the
> data it has read...these first lines appear in my memo after a few seconds
> and not directly :o(. Do you know how to use TRiderector? an example maybe
>
> Thank you
>

Hi Peter,

I don't have the TRedirector component handy and its link
seems to be down at the moment. Any other source ?
For DosCommand, I use the following and it's pretty fast, at
least with netstat or any other regular dos stuff:
-----------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
begin
DosCommand1.CommandLine := 'netstat -a';
DosCommand1.OutputLines := Memo1.Lines;
DosCommand1.Execute;
end;
-----------------------------------------------------

Jacques


Ryan Mills

unread,
Aug 19, 2004, 8:57:55 AM8/19/04
to
You have to declare a procedure on your form so that it follows the same
event declaration as the event OnLineAvailable.

What you may want to do is register the component in a package,
that way the IDE can create that for you.

The procedure you need to declare needs to look someting like this

Form1 = class(TForm)
private
procedure DoLineAvailable(Sender : TComponent; Line : string);
end;

HTH,
Ryan.

Peter S.

unread,
Aug 19, 2004, 9:11:27 AM8/19/04
to
Oberto, its in borland.public.attachments,send by Ryan Mills

"Jacques Oberto" <j...@nospam.com> wrote in message
news:4124...@newsgroups.borland.com...

0 new messages