yaronb
March 27th, 2001, 09:43 AM
I am trying to redirect a processes' IO , in such a way that I could , programmatically using VB commands, run Console commands (FTP for instance).
What I do is first create 4 pipes. InputWrite,InputRead,OutputWrite and OutputRead.
I initialize a STARTUPINFO structure the following way:
start.hStdOutput = OutputWrite
start.hStdInput = InputRead
And then create the process:
ret& = CreateProcessA(0&, "ftp node01", sa, sa, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
I then try to read the process' output , and that's when I come to a problem:
bSuccess = ReadFile(OutputWrite, mybuff, 100, bytesread, 0&)
The first call of the command succeeds partially, returning me some output in mybuff, but not all of it (the rest appearing on the console window).
And the second call for ReadFile just hangs the system.
Can anyone point me out to what I am doing wrong here? Pipes and redirecting are new to me..
Thanks,
Yaron.
What I do is first create 4 pipes. InputWrite,InputRead,OutputWrite and OutputRead.
I initialize a STARTUPINFO structure the following way:
start.hStdOutput = OutputWrite
start.hStdInput = InputRead
And then create the process:
ret& = CreateProcessA(0&, "ftp node01", sa, sa, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
I then try to read the process' output , and that's when I come to a problem:
bSuccess = ReadFile(OutputWrite, mybuff, 100, bytesread, 0&)
The first call of the command succeeds partially, returning me some output in mybuff, but not all of it (the rest appearing on the console window).
And the second call for ReadFile just hangs the system.
Can anyone point me out to what I am doing wrong here? Pipes and redirecting are new to me..
Thanks,
Yaron.