Telnet to cisco

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
 
M

Martijn Lievaart

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?

Use clogin from the rancid package, much easier.

M4
 
J

John Mason Jr

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

http://search.cpan.org/~joshua/Net-Telnet-Cisco-1.10/Cisco.pm


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,955
Messages
2,570,117
Members
46,705
Latest member
v_darius

Latest Threads

Top