Pipe question

May 20, 2008
11,285
95
Syracuse, NY, USA
If I do this in a plugin:

Code:
SetStdHandle(STD_OUTPUT_HANDLE, hPipe);
Command(Buffer, 0);
SetStdHandle(STD_OUTPUT_HANDLE, hSave);
and Buffer contains a compound command, like

Code:
echo foo & echo foo
only the output of the first ECHO makes it into the pipe. Is this my fault? Regardless, is there anything I can do to get all the output?

Thanks.
 

rconn

Administrator
Staff member
May 14, 2008
12,315
148
vefatica wrote:

> If I do this in a plugin:
>
>
> Code:
> ---------
> SetStdHandle(STD_OUTPUT_HANDLE, hPipe);
> Command(Buffer, 0);
> SetStdHandle(STD_OUTPUT_HANDLE, hSave);
> ---------
> and Buffer contains a compound command, like
>
>
> Code:
> ---------
> echo foo & echo foo
> ---------
> only the output of the first ECHO makes it into the pipe. Is this my fault? Regardless, is there anything I can do to get all the output?

Use a command group. Otherwise, Command() will undo the redirection
after the first command.

Rex Conn
JP Software
 
May 20, 2008
11,285
95
Syracuse, NY, USA
vefatica wrote:

SetStdHandle(..., hPipe);
Command(...);

Use a command group. Otherwise, Command() will undo the redirection
after the first command.

OK, but I also notice that if a single command produces more than one line of output (like DIR) only the first line is written to the pipe.
 

rconn

Administrator
Staff member
May 14, 2008
12,315
148
vefatica wrote:

> ---Quote (Originally by rconn)---
> vefatica wrote:
>
> SetStdHandle(..., hPipe);
> Command(...);
>
> Use a command group. Otherwise, Command() will undo the redirection
> after the first command.
> ---End Quote---
> OK, but I also notice that if a single command produces more than one line of output (like DIR) only the first line is written to the pipe.

Command() is where TCC processes all redirection. If you're going to do
your own redirection, don't call Command() as you're just going to cause
confusion and mayhem as TCC has no way of knowing what you've done.

If you want to do your own pipes, then you should use your own parsing &
output routines.

Rex Conn
JP Software
 
May 20, 2008
11,285
95
Syracuse, NY, USA
Use a command group. Otherwise, Command() will undo the redirection
after the first command.

And that doesn't seem to work. The pipe client sends `(echo foo & echo foo)`. The server sees it and reports: Remote command: (echo foo & echo foo). Then the server redirects the handle and calls Command(). But the client only sees (with some debug stuff):

Bytes read: 5
foo
102 111 111 13 10
 
May 20, 2008
11,285
95
Syracuse, NY, USA
Command() is where TCC processes all redirection. If you're going to do
your own redirection, don't call Command() as you're just going to cause
confusion and mayhem as TCC has no way of knowing what you've done.

If you want to do your own pipes, then you should use your own parsing &
output routines.

I was afraid of something like that. No thanks. :-(
 

rconn

Administrator
Staff member
May 14, 2008
12,315
148
vefatica wrote:

> ---Quote (Originally by rconn)---
> Use a command group. Otherwise, Command() will undo the redirection
> after the first command.
> ---End Quote---
> And that doesn't seem to work. The pipe client sends `(echo foo & echo foo)`. The server sees it and reports: Remote command: (echo foo & echo foo). Then the server redirects the handle and calls Command(). But the client only sees (with some debug stuff):
>
> Bytes read: 5
> foo
> 102 111 111 13 10

I have no idea what you're trying to do, but it almost certainly won't
work with Command(), which is going to be unhappy with your redirection
attempts. (And which is going to promptly undo them!)

Rex Conn
JP Software
 
Similar threads
Thread starter Title Forum Replies Date
vefatica Test for right side of a pipe? Plugins 4
vefatica Tough (?) programming question Plugins 5
vefatica Question about screen buffer handles Plugins 2
vefatica Question for someone with sysutils and Windows 10 Plugins 4
vefatica Question for Rex Plugins 1
Charles Dye SearchPaths() question Plugins 4
vefatica Question for Rex Plugins 0
Charles Dye A weirdoid plugin question Plugins 6
Charles Dye Keystroke plugins question Plugins 7
vefatica A question for Rex Plugins 5
S How to? SafeChars.dll question Plugins 4
Charles Dye Binary buffers question Plugins 0
M Just a curiosity question related to the "default" set of re-mapped characters... Plugins 2
vefatica Question about Ctrl events Plugins 2
vefatica Generic programming question Plugins 2
vefatica Compiler question Plugins 8
vefatica Plugin keyhandler observation/question Plugins 15
vefatica PLUGININFO question Plugins 9
vefatica Plugin keyhandler question Plugins 1
vefatica Code page question Plugins 2
vefatica Unicode question (revisited, question for Rex) Plugins 0
vefatica Sprintf question Plugins 1
vefatica Unicode question Plugins 13
vefatica Question about GetToken() Plugins 7
vefatica Plugin question Plugins 3
vefatica Another Sscanf question Plugins 1
vefatica NthArgument() question Plugins 1
vefatica Ctrl handling question Plugins 8
vefatica Message pumping question Plugins 12

Similar threads