B
Bogus
Hi,
I need to write a telnet client through which I will connect to cisco
(router/switch) but it must be as much similar to normal telnet client
as possible - right now I wrote very simple telnet client but it doesn't
work like I want e.g. when I send command "show ip bgp" which shows
whole bgp table normal telnet wait for space to show next page of
prefixes but my script doesn't work in this place
I need to use this script like a normal telnet client - is it possible?
Reason: I need to format some data which is send to console
This is the code which I found:
use IO::Socket;
$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr=> "remote-ip",
PeerPort=> "23",
) or die "cannot connect to remote-ip";
$remote->autoflush(1);
print STDERR "[Connected to $host:$port]\n";
die "can't fork: $!" unless defined($kidpid = fork());
if ($kidpid) {
while (defined ($line = <$remote>)) {
print STDOUT $line;
}
kill("TERM", $kidpid); # send SIGTERM to child
}
else {
while (defined ($line = <STDIN>)) {
print $remote $line;
}
}
Thanks
I need to write a telnet client through which I will connect to cisco
(router/switch) but it must be as much similar to normal telnet client
as possible - right now I wrote very simple telnet client but it doesn't
work like I want e.g. when I send command "show ip bgp" which shows
whole bgp table normal telnet wait for space to show next page of
prefixes but my script doesn't work in this place
I need to use this script like a normal telnet client - is it possible?
Reason: I need to format some data which is send to console
This is the code which I found:
use IO::Socket;
$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr=> "remote-ip",
PeerPort=> "23",
) or die "cannot connect to remote-ip";
$remote->autoflush(1);
print STDERR "[Connected to $host:$port]\n";
die "can't fork: $!" unless defined($kidpid = fork());
if ($kidpid) {
while (defined ($line = <$remote>)) {
print STDOUT $line;
}
kill("TERM", $kidpid); # send SIGTERM to child
}
else {
while (defined ($line = <STDIN>)) {
print $remote $line;
}
}
Thanks