David Gibbs <dagibbs@qnx.com> wrote:
: “Mgr. Martin Gazak” <matog@microstep-hdo.sk> wrote:
: Depending on the ftp client – some of them force an open to /dev/tty
: (alias for their controlling terminal, not stdin), especially if they
: need to prompt for a password. This could be a problem, and the usual
: solution is to actually use a pseudo-tty for control. (Advanced
: Programming in the Unix Environment by W. Richard Stevens has a good
: chapter on this.)
: There are also ftp libraries around that can make this easier than trying
: to control a client through strings.
: Have you tried, just as a test, working with something simpler than
: ftp as the controlled program? Maybe something like cat, which will
: just write its stdin to it stdout to make sure you’ve got everything
: setup properly?
: In theory, though, what you are trying to do should work.
There is one more thing, you could do, use a .netrc file to get
pass the authentication. Also there is a the option ‘-n’
to disable the auto-login which probably call getpass() or something
similar in any case it needs a real pty to turn off echoing etc …
if you use -n you will have to call User/Pass your self after the connection
With the .netrc there is a security, I beleive it has to be a certain
mode for it to work.
Good luck.
: -David
:> Hello,
:> I have following problem. What I wanted to write a program, that creates
:> two pipes, forks, first pipe connects to child’s stdin using dup2, second
:> pipe connects to child’s stdout and the child calls
:> execl( … ) to become an ftp client.
:> The purpose of the pipes was to send commands to the ftp through the first
:> pipe and to receive responses through the second. The problem was, that the
:> read on the second pipe blocks … ( Reply block
:> on the process Pipe)
:> What I tried to solve the problem :
:> - setting some flags ( O_NONBLOCK ) on the fd
:> - replacing the exec() call in a child program by a piece of code, that
:> reads from stdin a echoes the input
:> to stdout ( using read(), write() functions ). This worked …
:> - writing to ftp’s stdin block with the length PIPE_BUF (limits.h)
:> Maybe I just try something, that under QNX ( Unix ) does not work. But
:> something like this is used
:> e.g. in debuggers ( DDD, pdb ), that run gdb and just visualize code and
:> data.
:> Thanks for answer.
:> Mgr. Martin Gazak
:> tel.:++421 7 60291 816
:> e-mail: matog@microstep-hdo.sk
\
au revoir, alain
Aussi haut que l’on soit assis, on n’est toujours assis que sur son cul !!!