Re: [fpc-pascal] Redirecting input to a child process

2011-05-19 Thread Anton Shepelev
Sorry, I forgot to say the patch is against verstion 2.4.2. Anton ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Redirecting input to a child process

2011-05-19 Thread Anton Shepelev
Michael Van Canneyt: > The interface of the pipes unit can be changed > with a parameter with a default value, so existing > code continues to work. Yes, but all the platform-specific pipe.inc files and pipes.pp will have to be changed anyway because the CreatePipeHandles will have a di

Re: [fpc-pascal] Redirecting input to a child process

2011-05-18 Thread Michael Van Canneyt
On Thu, 19 May 2011, Anton Shepelev wrote: Ludo Brands: You can file a bug at http://bugs.freepascal.org/. This is bug #0019325. ... I thought about writing a patch, but it seems that it is not enough to modify the implementation of the Windows-specific pipes.inc. The correct way to cre

Re: [fpc-pascal] Redirecting input to a child process

2011-05-18 Thread Anton Shepelev
Ludo Brands: > You can file a bug at http://bugs.freepascal.org/. This is bug #0019325. ... I thought about writing a patch, but it seems that it is not enough to modify the implementation of the Windows-specific pipes.inc. The correct way to create pipes for the three channels (out, in and er

Re: RE : [fpc-pascal] Redirecting input to a child process

2011-05-18 Thread Anton Shepelev
A little update on the subject. Ludo Brands wrote: > If you run 'more' in a cmd window you'll notice that > 'more' echoes the input but only sends to stdout when a > return is entered. I modified the program to send > 'Anton'#10 and the program reads back 'Anton'#10 from std- >

Re: RE : RE : RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-09 Thread Henry Vermaak
On 09/05/11 12:04, Anton Shepelev wrote: Ludo Brands: If you need these handles from the child process use: InHnd:=GetStdHandle(STD_INPUT_HANDLE); OutHnd:=GetStdHandle(STD_OUTPUT_HANDLE); ErrHnd:=GetStdHandle(STD_ERROR_HANDLE); Thank you, that's what I need. By the way, it does work in a sim

Re: RE : RE : RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-09 Thread Anton Shepelev
Ludo Brands: > If you need these handles from the child process use: > InHnd:=GetStdHandle(STD_INPUT_HANDLE); > OutHnd:=GetStdHandle(STD_OUTPUT_HANDLE); > ErrHnd:=GetStdHandle(STD_ERROR_HANDLE); Thank you, that's what I need. By the way, it does work in a simple single-process applica- tion:

Re: RE : [fpc-pascal] Redirecting input to a child process

2011-05-09 Thread Anton Shepelev
Ludo Brands: > You can file a bug at http://bugs.freepascal.org/ OK. > Dupicating handles isn't apparently the only solution. The > msdn sample creates non-inheritable pipes and hands these > handles simply over to createprocess, without duplicating. There are two solutions, but only of them

RE : RE : RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-09 Thread Ludo Brands
-boun...@lists.freepascal.org] De la part de Ludo Brands Envoyé : lundi 9 mai 2011 07:51 À : 'FPC-Pascal users discussions' Objet : RE : RE : RE : [fpc-pascal] Redirecting input to a child process Pipe handles can be used directly with readfile: Var BytesRead:Longword; windows.Readfile(mProcess.Outpu

RE : [fpc-pascal] Redirecting input to a child process

2011-05-09 Thread Ludo Brands
011 00:22 À : fpc-pascal@lists.freepascal.org Objet : Re: [fpc-pascal] Redirecting input to a child process I wrote: > I'll try duplicating the handles and report the results. Yes. It works now. I am creating a non-inheritable handle using CreatePipe, then duplicating it to an inheritable o

RE : RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-09 Thread Ludo Brands
-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Anton Shepelev Envoyé : dimanche 8 mai 2011 22:26 À : FPC-Pascal users discussions Objet : Re: RE : RE : [fpc-pascal] Redirecting input to a child process Ludo Brands: > > Connected with this remark, is there a way

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread waldo kitty
On 5/8/2011 16:16, Anton Shepelev wrote: waldo kitty: how about sending the ^Z line the CRLF is being sent to indicate line breaks?? This I had tried even before posting the question :) i wasn't sure and the posts didn't seem to indicate this so i thought i'd ask ;) now i'll go back to

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
I wrote: > I'll try duplicating the handles and report the results. Yes. It works now. I am creating a non-inheritable handle using CreatePipe, then duplicating it to an inheritable one using DuplicateHandle and pass the duplicate to the CreateProcess funtion. Does this mean that th

Re: RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Ludo Brands: > > Connected with this remark, is there a way to get the > > underlying StdIn handle in a FreePascal program, so as > > to read from it per-character, or any other way using > > the OS's routines? > > The handles are mProcess.Input.Handle and mProcess.Out- > put.Handle I

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
waldo kitty: > how about sending the ^Z line the CRLF is being sent to > indicate line breaks?? This I had tried even before posting the question :) Ludo Brands: > I don't see where you close the mProcess.input. In my original post I call: MoreProcess.CloseInput(); As for the progra

RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
users discussions Objet : RE : [fpc-pascal] Redirecting input to a child process Ludo Brands: > If you run 'more' in a cmd window you'll notice that 'more' > echoes the input but only sends to stdout when a > return is entered. I modified the

RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
d". Ludo -Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de waldo kitty Envoyé : dimanche 8 mai 2011 20:29 À : fpc-pascal@lists.freepascal.org Objet : Re: RE : [fpc-pascal] Redirecting input to a child

Re: RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread waldo kitty
On 5/8/2011 13:17, Anton Shepelev wrote: Ludo Brands: If you run 'more' in a cmd window you'll notice that 'more' echoes the input but only sends to stdout when a return is entered. I modified the program to send 'Anton'#10 and the program reads back 'Anton'#10 from stdou

RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
Objet : Re: RE : [fpc-pascal] Redirecting input to a child process Ludo Brands: > If you run 'more' in a cmd window you'll notice that 'more' > echoes the input but only sends to stdout when a > return is entered. I modified the program to se

RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
s.freepascal.org] De la part de Anton Shepelev Envoyé : dimanche 8 mai 2011 19:18 À : FPC-Pascal users discussions Objet : RE : [fpc-pascal] Redirecting input to a child process Ludo Brands: > If you run 'more' in a cmd window you'll notice that 'more' >

Re: RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Ludo Brands: > If you run 'more' in a cmd window you'll notice that > 'more' echoes the input but only sends to stdout when a > return is entered. I modified the program to send > 'Anton'#10 and the program reads back 'Anton'#10 from > stdout. Connected with this remark, is

RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Ludo Brands: > If you run 'more' in a cmd window you'll notice that > 'more' echoes the input but only sends to stdout when a > return is entered. I modified the program to send > 'Anton'#10 and the program reads back 'Anton'#10 from > stdout. Thank you, Ludo, this is great

RE : RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
x27;FPC-Pascal users discussions' Objet : RE : [fpc-pascal] Redirecting input to a child process If you run 'more' in a cmd window you'll notice that 'more' echoes the input but only sends to stdout when a return is entered. I modified the program to send 'Anto

RE : [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Ludo Brands
--Message d'origine- De : fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] De la part de Marco van de Voort Envoyé : dimanche 8 mai 2011 18:06 À : FPC-Pascal users discussions Objet : Re: [fpc-pascal] Redirecting input to a child process In our previous episode, A

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Marco van de Voort: > I played a bit with it, but was unable to make it work. I > added a writeln of outstream.size to the "running" while, > and it seems output is written. Many thanks :) If I understood you correctly, you put WriteLn(MoreProcess.Output.Size); inside the waiting loop an

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Marco van de Voort
In our previous episode, Anton Shepelev said: > > > shell, isn't the shell's input redirected to the > > > program's? > > > > Maybe. I'm pretty sure about batchfiles, but never > > tried programs, that's why I thought I'd mention > > the observation. > > My program captures both the standard and

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Marco van de Voort: > > When executing command-line programs via the > > shell, isn't the shell's input redirected to the > > program's? > > Maybe. I'm pretty sure about batchfiles, but never > tried programs, that's why I thought I'd mention > the observation. My program captures both the

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Marco van de Voort
In our previous episode, Anton Shepelev said: > > When executing command-line programs via the shell, > isn't the shell's input redirected to the program's? Maybe. I'm pretty sure about batchfiles, but never tried programs, that's why I thought I'd mention the observation. __

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
Marco van de Voort: > Why do you execute over the shell? You now pipe > your information into the shell (since that is > what you execute directly), not the program. Thanks for the note, Marco. Unfortunately, replacing that line with the direct path to more.com had no effect. When exe

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
SteveG: > This is working on Linux and WinXP > > I cut what I was hoping was just the relevant code > from the unit, so it is missing a bit :) Here's a full program made from this code: http://pastebin.com/id90J1rY It doesn't work for me in WinXP. What about you? Anton

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Marco van de Voort
In our previous episode, Anton Shepelev said: >MoreProcess.CommandLine := 'C:\WINDOWS\system32\cmd.exe /C more'; Why do you execute over the shell? You now pipe your information into the shell (since that is what you execute directly), not the program. ___

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread SteveG
On 08/05/11 17:30, Anton Shepelev wrote: SteveG: Anton - I have attached an extract from some work- ing code (hopefully I didnt remove anything neces- sary) It may help you move on a bit further I turned your piece of code into a complete program, but it didn't work either. In fact, there

Re: [fpc-pascal] Redirecting input to a child process

2011-05-08 Thread Anton Shepelev
SteveG: > Anton - I have attached an extract from some work- > ing code (hopefully I didnt remove anything neces- > sary) > It may help you move on a bit further I turned your piece of code into a complete program, but it didn't work either. In fact, there is not much difference between yo

Re: [fpc-pascal] Redirecting input to a child process

2011-05-07 Thread SteveG
On 08/05/11 05:38, Anton Shepelev wrote: Hello all, I have been experimenting with redirection of stan- dard I/O of child processes using FreePascal 2.4.2 on Windows. I have succeeded in capturing standard input and standard output, but failed to feed my own data to the child's standard inp