[LCP]interactive Telnet session
Charles Randle
charlesrandle at yahoo.com
Tue Sep 3 11:00:53 UTC 2002
Lucas King ,
What about output from STDERR (fd = 2) ? Have you
handled this as well ?
Best Regards,
Charles Randle
--- Lucas King <lking at fp.fairfax.com.au> wrote:
> 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.
>
************************************************************************
>
>
> _______________________________________________
> This is the Linux C Programming List
> :
> http://lists.linux.org.au/listinfo/linuxcprogramming
List
__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
More information about the linuxCprogramming
mailing list