DX NetOps

 View Only
  • 1.  "enter" is showing with a extrange characters

    Posted Jan 24, 2018 07:09 AM

    I have done recently a script to capture the running config in the switch Aruba by Spectrum. It works fine except there is an "Enter" before the config starting, and this "enter" is showing with a extrange characters in the Spectrum:

     

    "enter" is showing with a extrange characters in the Spectrum.

     

    Is there anyone who knows how  can I delete this characters?



  • 2.  Re: "enter" is showing with a extrange characters

    Broadcom Employee
    Posted Jan 26, 2018 06:35 AM

    Hi Susana,

     

    Can you run only the lines to capture the config directly on the device and see how it is coming.

     

    or if you could update the script which you are using to this post then someone can suggest.

     

    Regards

    Sunny



  • 3.  Re: "enter" is showing with a extrange characters
    Best Answer

    Posted Jan 30, 2018 07:31 AM

    Resolved it!


    There were ANSI characters to select the cursor position and put it in colors. There was no way to delete it in origin, the router.

    Through other forum about perl programation they have given me the solution, find the character in the first line to start capture and discard everything before that point.

     

    This is the part of the script to capture and edit the config

    $telnet->print("screen-length 1000");
    $telnet->print("page");
    $telnet->print( "show running structured " );
    ####################QUITO CARACTERES ANSI##################
    #Empezamos estando en la cabecera
    my $en_cabecera = 1;
    while (my $line = $telnet->getline())
    {
    #quitamos fin de linea
    chomp $line;
    #Si estamos $en_cabecera y la $line comienza por un ';'
    if ($en_cabecera and $line =~ /^[;]/)
    {
    #Ya no estamos $en_cabecera
    $en_cabecera =0;
    }
    #Si aun estamos $en_cabecera, saltamos a la liniea siguiente
    next if $en_cabecera;

    # get configuration content
    if( $line !~ / Configuration Editor|Running configuration:|^\s*$/ )
    {

    $line =~ s/\s+$//g;
    push @config, $line;
    push @config, "\n";
    }
    }
    $telnet->waitfor('/.*#/');
    if( $telnet->errmsg )
    {
    $msg = "No prompt after 'display current-configuration': ".$telnet->errmsg;
    $telnet->close( );
    exit 258;
    }

    if( @config <= 0 )
    {
    $msg = "No data retrieved, the capture timeout may be too low.";
    $telnet->close();
    exit 252;
    }
    if( scalar grep {$_ =~ /^%/} @_ )
    {
    # Ensure show run actually returned the config and not an error message containing '%'
    exit 253;
    }

    for( @config ) { print };
    $telnet->close( );

    exit 0;
    }