[LCP]interactive Telnet session
Lucas King
lking at fp.fairfax.com.au
Mon Sep 2 05:31:06 UTC 2002
Hello,
i am attempting to write a small C program, on a Linux box running
Redhat 7.2, that allows me to interact with a Telnet session. i firstly
create a socketpair, then fork. in the child process i start a Telnet
session, listed below, after "redirecting" the input/output to my
socket. the parent process, not listed here, monitors the socket pair
and takes appropriate action depending on what i have stated in a
response file. the parent, when not active blocks on a read from the
socket.
this program is mostly successful in that i am able to login and out.
but i have one problem which i have been banging my head against for
several days now. for reasons that i am unaware, the Telnet session
does not send all of its (display) output to the socket that i have
created. instead it writes it directly to the display. this occurs
just after i login to the remote system. two sets of "strange"
characters appear on the screen. after approximately 10 seconds the
Telnet session reports that it is unable to set two variables. i am
assuming that it is attempting to query the terminal type but is not
receiving a response.
how does one go about fixing/resolving this problem?
int main( void )
{
pid_t pid;
int fds[2];
.
if ( socketpair( AF_INET, SOCK_DGRAM, 0, fds ) < 0 ) . . . error
handling;
pid = fork();
.
.
} /* end function */
int child_process( int fd )
{
if ( ( fd = dup2( 0, fd ) ) < 0 ) return 1;
if ( ( fd = dup2( 0, fd ) ) < 0 ) return 1;
execlp( "telnet", "telnet", "128.8.8.8", NULL );
return 0;
} /* end function */
any suggestions would/will be most appreciated.
thanking you in advance,
Lucas King
************************************************************************
This email and any files transmitted with it may be legally privileged
and confidential. If you are not the intended recipient of this email,
you must not disclose or use the information contained in it. If you
have received this email in error, please notify us by return email and
permanently delete the document.
************************************************************************
More information about the linuxCprogramming
mailing list