Other Remove "...[C[0k" from expect output

Dear all,

How can I not generate the substring ...[C[C[C[0k after issued comands trough expect scripts?
For example, I have the following lines in an expect script:
Code:
#set variables, parameters etc
...
spawn telnet $IP $PORT
expect -nocase "name:"
send -- "$USER\r"
expect -nocase "password:"
send -- "$PASS\r"
expect -re "$prompt"
send -- "terminal length 0\r"
expect -re "$prompt"
send -- "show vlan\r"
expect -re "$prompt"
send -- "logout\r"
expect eof
After execution I receive the undesirable substrings:
Code:
Username:[C[C[C[C[C[C[C[C[C[0Kadmin
Password:[C[C[C[C[C[C[C[C[C[0K**************
switch#
[C[C[C[C[C[C[C[C[C[0Kterminal length 0
switch#[C[C[C[C[C[C[C[C[C[0Kshow vlan
...
#'show vlan' command result here
...
switch#[C[C[C[C[C[C[C[C[C[0Klogout
Connection closed by foreign host.
Does anyone have a tip on how can I not generate these "[C[C[C[C[C[C[C[C[C[0K" strings? Other issue is that I cannot use other tool to remove the strings, I need that expect not generate then.
 
Not related to the error but I would suggest taking a different approach. For starters, enable SSH instead of Telnet on your Cisco equipment. And instead of expect(1) I would use Net::SSH Perl modules. This will be much safer (encrypted connection, stronger authentication) and a lot less error-prone.
 
Back
Top