Problem using pipes to run ftp

I’m trying to run an ftp session by opening 2 pipes in my main app and then
spawning the “ftp” utility with the write end of one of the pipes assigned
to stdout of the spawned “ftp” and the read end of the other pipe assigned
to the stdin of “ftp”. I can write to the ftp’s stdin through the one pipe
successfully (I see it make a connection and open another fd to the server).
If, I also assign ftp’s stderr to same pipe as its stdout, I can read error
messages from ftp in my main app. However, I’m unable to read anything from
the pipe that should be directed to ftp’s stdout.

I note from “sin fd” that fd’s 0,1,2 are all marked as being connected to
“pipe”. I also note that ftp has no other fd’s open (until I open an ftp
session by writing through the pipe to ftp’s stdin).

If I replace ftp by my own app that simply writes something to its stdout, I
can read that output from the pipe in my main program

If I replace ftp by telnet, I see the normal telnet stdout output delivered
along the pipe.

What’s special about ftp’s stdout in this scenario? - anyone have any ideas



Lionel J Johnson
Sterling Computer Systems Inc.
19270 North Hills Drive
Brookfield, Wisconsin 53045
Telephone: +1 (262) 796-0063
Fax: +1 (262) 796-1225

Lionel Johnson ljohnson**nospam** wrote:

At some point – definitely for prompting for a password – ftp
does an open("/dev/tty") and reads from that. This gets the
controlling terminal.

If you’re controlling something like ftp, you have to use a pseudo-tty
between you and ftp, rather than a pair of pipes.

Or, there are ftp protocol in library form libraries also available –
do a search for libftp on qdn (or, on the web).


QNX Training Services