Discussion:
[rancid] Cisco ACS 5.5
Paweł Rzepa
2014-04-29 11:57:57 UTC
Permalink
Hi,
I use rancid to download configuration from Cisco ACS. I have adopted
rancid a little and finally got it working. After recent upgrade to
5.5 it stopped gathering configuration.
Investigation showed that the reason was exp_continue in proc
run_commands for -re "\b+" :
proc run_commands { prompt command } {
global do_saveconfig in_proc platform
...
for {set i 0} {$i < $num_commands} { incr i} {
send -- "[subst -nocommands [lindex $commands $i]]\r"
expect {
# -re "\b+" { exp_continue } --------------
MUST HAVE DISABLED IT
-re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)"
}
-re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)"
exp_continue
}
...........


Now I got all the configuration lines, but '\b' is here. How can I
remove all occurrences of '\b' from the buffer before it is printed
out?

Regards,
Pawel Rzepa
heasley
2014-04-29 13:54:54 UTC
Permalink
Post by Paweł Rzepa
Hi,
I use rancid to download configuration from Cisco ACS. I have adopted
rancid a little and finally got it working. After recent upgrade to
5.5 it stopped gathering configuration.
Investigation showed that the reason was exp_continue in proc
proc run_commands { prompt command } {
global do_saveconfig in_proc platform
...
for {set i 0} {$i < $num_commands} { incr i} {
send -- "[subst -nocommands [lindex $commands $i]]\r"
expect {
# -re "\b+" { exp_continue } --------------
MUST HAVE DISABLED IT
-re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)"
}
-re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)"
exp_continue
}
...........
Now I got all the configuration lines, but '\b' is here. How can I
remove all occurrences of '\b' from the buffer before it is printed
out?
the line that you have commented should have consumed the backspaces.
what is the behavior when it fails (hangs, simply fails)? what version
of expect do you have? what version of rancid?
Paweł Rzepa
2014-04-30 07:13:28 UTC
Permalink
Hi,
No, it doesn't hang. When I login into the device interactively it
works. When I run a command it produces unpredictable results, imho
depending on the chunks of output retrieved from the device.

This is the excerpt from clogin -d -c 'write term' output which I
suppose is relevant to the issue:

expect: does "ip domain-name my.company.com\r\n! \r\nno ipv6
enable\r\n! \r\ninterface GigabitEthernet 0\r\n ip address
10.10.10.10 255.255.255.0\r\n ipv6 address autoconfig\r\n no ipv6
enable\r\n! \r\ninterface GigabitEthernet 1\r\n shutdown\r\n
ipv6 address autoconfig\r\n no ipv6 enable\r\n! \r\nip
name-server 10.10.10.10 10.10.10.10 \r\n! \r\nip
default-gateway 10.10.10.10\r\n! \r\nclock timezone
Europe/Warsaw\r\n! \r\nntp server
10.10.10.10\r\n!\u0008\nusername root password hash
$1$p4MxVbAdp$asdfasdfasdfasd role admin \r\n!\u0008\nno
max-ssh-sessions\r\n!\u0008\n" (spawn_id exp6) match regular
expression "\u0008+"? yes
expect: set expect_out(0,string) "\u0008"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "ip domain-name my.company.com\r\n!
\r\nno ipv6 enable\r\n! \r\ninterface GigabitEthernet 0\r\n
ip address 10.10.10.10 255.255.255.0\r\n ipv6 address autoconfig\r\n
no ipv6 enable\r\n! \r\ninterface GigabitEthernet 1\r\n
shutdown\r\n ipv6 address autoconfig\r\n no ipv6 enable\r\n!
\r\nip name-server 10.10.10.10 10.10.10.10 \r\n! \r\nip
default-gateway 10.10.10.10\r\n! \r\nclock timezone
Europe/Warsaw\r\n! \r\nntp server 10.10.10.10\r\n!\u0008"
expect: continuing expect

expect: does "\nusername root password hash
$1$p4MxVbAdp$asdfasdfasdfasd role admin \r\n!\u0008\nno
max-ssh-sessions\r\n!\u0008\n" (spawn_id exp6) match regular
expression "\u0008+"? yes
expect: set expect_out(0,string) "\u0008"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "\nusername root password hash
$1$p4MxVbAdp$asdfasdfasdfasd role admin \r\n!\u0008"
expect: continuing expect

expect version 5.43.0
rancid 2.3.8

Regards,
Pawel Rzepa
Post by heasley
Post by Paweł Rzepa
Hi,
I use rancid to download configuration from Cisco ACS. I have adopted
rancid a little and finally got it working. After recent upgrade to
5.5 it stopped gathering configuration.
Investigation showed that the reason was exp_continue in proc
proc run_commands { prompt command } {
global do_saveconfig in_proc platform
...
for {set i 0} {$i < $num_commands} { incr i} {
send -- "[subst -nocommands [lindex $commands $i]]\r"
expect {
# -re "\b+" { exp_continue } --------------
MUST HAVE DISABLED IT
-re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)"
}
-re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)"
exp_continue
}
...........
Now I got all the configuration lines, but '\b' is here. How can I
remove all occurrences of '\b' from the buffer before it is printed
out?
the line that you have commented should have consumed the backspaces.
what is the behavior when it fails (hangs, simply fails)? what version
of expect do you have? what version of rancid?
heasley
2014-05-01 20:56:45 UTC
Permalink
Post by Paweł Rzepa
Hi,
No, it doesn't hang. When I login into the device interactively it
works. When I run a command it produces unpredictable results, imho
depending on the chunks of output retrieved from the device.
This is the excerpt from clogin -d -c 'write term' output which I
expect: does "ip domain-name my.company.com\r\n! \r\nno ipv6
enable\r\n! \r\ninterface GigabitEthernet 0\r\n ip address
10.10.10.10 255.255.255.0\r\n ipv6 address autoconfig\r\n no ipv6
enable\r\n! \r\ninterface GigabitEthernet 1\r\n shutdown\r\n
ipv6 address autoconfig\r\n no ipv6 enable\r\n! \r\nip
name-server 10.10.10.10 10.10.10.10 \r\n! \r\nip
default-gateway 10.10.10.10\r\n! \r\nclock timezone
Europe/Warsaw\r\n! \r\nntp server
10.10.10.10\r\n!\u0008\nusername root password hash
$1$p4MxVbAdp$asdfasdfasdfasd role admin \r\n!\u0008\nno
max-ssh-sessions\r\n!\u0008\n" (spawn_id exp6) match regular
expression "\u0008+"? yes
expect: set expect_out(0,string) "\u0008"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "ip domain-name my.company.com\r\n!
\r\nno ipv6 enable\r\n! \r\ninterface GigabitEthernet 0\r\n
ip address 10.10.10.10 255.255.255.0\r\n ipv6 address autoconfig\r\n
no ipv6 enable\r\n! \r\ninterface GigabitEthernet 1\r\n
shutdown\r\n ipv6 address autoconfig\r\n no ipv6 enable\r\n!
\r\nip name-server 10.10.10.10 10.10.10.10 \r\n! \r\nip
default-gateway 10.10.10.10\r\n! \r\nclock timezone
Europe/Warsaw\r\n! \r\nntp server 10.10.10.10\r\n!\u0008"
expect: continuing expect
hrm, that does not work as intended. this match has been there unchanged
since 2001. would you try this patch with your asa?

Index: bin/clogin.in
===================================================================
--- bin/clogin.in (revision 2828)
+++ bin/clogin.in (working copy)
@@ -656,7 +656,7 @@
for {set i 0} {$i < $num_commands} { incr i} {
send -- "[subst -nocommands [lindex $commands $i]]\r"
expect {
- -re "\b+" { exp_continue }
+ -re "^\b+" { exp_continue }
-re "^\[^\n\r *]*$reprompt" { send_user -- "$expect_out(buffer)"
}
-re "^\[^\n\r]*$reprompt." { send_user -- "$expect_out(buffer)"

Loading...