Chris Green <[EMAIL PROTECTED]> typed:
: I have a short 'C' program which automates login via telnet to a
: remote system. I.e. the 'C' program uses ioctl(fd, TIOCSTI, cp) to
: stuff the following into the keyboard buffer:-
: "telnet -l chris <name of system>\n"
: It then sleeps for a few seconds and stuffs the password for the
: remote system into the keyboard buffer.
OK, here's a quick version I just whipped up. Worked fine for me.
I didn't bother putting in several checks for correct handling.
If you want to start it without using passwords wouldn't using
rlogin or ssh be easier? e.g. "rxvt -e rlogin -l chris somesystem"
#include <stdio.h>
#include <sys/ioctl.h>
main()
{
int i;
char *cp;
char buf1[] = "username\n";
char buf2[] = "password\n";
switch(fork()) {
default: /* parent must do this bit */
execl("/usr/bin/telnet", "telnet", "192.168.1.1", NULL);
fprintf(stderr, "execl() failed\n");
exit(1);
case 0:
break;
}
/* in the hands of a child */
sleep(5);
for (cp = buf1, i = sizeof(buf1); --i; cp++)
if (ioctl(0, TIOCSTI, cp) == -1)
exit(2);
sleep(2);
for (cp = buf2, i = sizeof(buf2); --i; cp++)
if (ioctl(0, TIOCSTI, cp) == -1)
exit(2);
/* child terminated. parent lives */
}
Regards,
--
Geoff Wing : <[EMAIL PROTECTED]>
Rxvt Stuff : <[EMAIL PROTECTED]>
Zsh Stuff : <[EMAIL PROTECTED]>