Telnet to cisco

Discussion in 'Perl Misc' started by Bogus, Feb 21, 2011.

  1. Bogus

    Bogus Guest

    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
    Bogus, Feb 21, 2011
    #1
    1. Advertising

  2. On Mon, 21 Feb 2011 13:01:53 +0100, Bogus wrote:

    > 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
    Martijn Lievaart, Feb 21, 2011
    #2
    1. Advertising

  3. On 2/21/2011 7:01 AM, Bogus wrote:
    > 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
    John Mason Jr, Feb 21, 2011
    #3
  4. Bogus

    BoguÅ› Guest

    BoguÅ›, Feb 23, 2011
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. h4fun

    Cisco and telnet

    h4fun, Oct 18, 2007, in forum: Java
    Replies:
    1
    Views:
    452
    Esmond Pitt
    Oct 19, 2007
  2. Pablo Zorzoli

    Ruby & Telnet & Cisco

    Pablo Zorzoli, Mar 30, 2007, in forum: Ruby
    Replies:
    7
    Views:
    665
    Brian Candler
    Apr 2, 2007
  3. Carcarius
    Replies:
    0
    Views:
    275
    Carcarius
    Dec 6, 2007
  4. jackster the jackle

    Net:Telnet to Cisco Router

    jackster the jackle, Dec 14, 2007, in forum: Ruby
    Replies:
    5
    Views:
    288
    jackster the jackle
    Dec 17, 2007
  5. Bhaskar Kurapati

    Net::Telnet::Cisco->enable always return 1

    Bhaskar Kurapati, Sep 10, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    88
    Bhaskar Kurapati
    Sep 10, 2003
Loading...

Share This Page