Article View: comp.lang.pascal.delphi.misc
Article #480Problem writing to stdin of a console program (cvs.exe). Help?
From: Murray McCulloch
Date: Tue, 20 Jan 2004 23:26
Date: Tue, 20 Jan 2004 23:26
36 lines
2661 bytes
2661 bytes
I'm trying to control CVS from a GUI application. I have no trouble executing cvs.exe and collecting its output, but I've had no luck trying to send input to it when it prompts for a password (cvs logon command). I'm creating a pipe and setting the hStdInput field of TStartupInfo to the read end before I create the process. Same thing with hStdOut and hStdIn (using a second pipe of course). Peeking at the stdout pipe, I see CVS's password prompt. But when I try to write to the stdin pipe, I get an invalid handle error. I've tried WriteFile(), WriteConsole() and WriteConsoleInput(). Another hint that something is wrong is that the CVS process seems to run away - CPU goes to 100% and the process doesn't end until I kill it. It's no surprise that it doesn't end, since it's waiting for input, but why the 100% CPU time? I thought this might be something to do with the cvs.exe itself -- I read somewhere that not all programs are written in a way that they will allow you to redirect standard input. So I tried to write a simple console app of my own to test the theory, but I couldn't even get my own app to redirect output, let alone input. (It was a simple writeln/readln thing -- I guess I needed to do more?) I've read tons of threads about redirecting output and input of console programs and tried everything I've read, but I cannot get cvs.exe to accept my input. If anyone has any thoughts about what I might be doing wrong, or happens to know if CVS just won't allow this (and if so, is there a work-around?), your replies would be greatly appreciated. I've had the same results from both CVSNT and the bona fide CVS Win32 binary. Cheers, MM
Technical Details
Message-ID:
<9fa254af.0401201526.601ef971@posting.google.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1091e5,cf4a6cc472dc4b64,start X-Google-Attributes: gid1091e5,public X-Google-Thread: 10baee,cf4a6cc472dc4b64,start X-Google-Attributes: gid10baee,public X-Google-ArrivalTime: 2004-01-20 15:26:46 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail From: mrmdotnet@yahoo.com (Murray McCulloch) Newsgroups: comp.lang.pascal.delphi.misc,borland.public.delphi.winapi Subject: Problem writing to stdin of a console program (cvs.exe). Help? Date: 20 Jan 2004 15:26:46 -0800 Organization: http://groups.google.com Lines: 36 Message-ID: <9fa254af.0401201526.601ef971@posting.google.com> NNTP-Posting-Host: 12.173.168.196 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1074641206 12059 127.0.0.1 (20 Jan 2004 23:26:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 20 Jan 2004 23:26:46 +0000 (UTC)