[rancid] run_commands not liking eof/end of session

Josh Rogers 2010 at tybox.net
Wed Mar 30 03:04:02 UTC 2011


>> > $ expect -v
>> > expect version 5.43.0

Ubuntu 10.04.  Originally I had the ubuntu maintainers version of
expect/tcl installed, but the above was downloaded and compiled from
shrubbery.net.  When looking closer, it appears that ssh is being
spawned twice?



$ jlogin rtr1 "show system users"
rtr1
spawn ssh -c 3des -x -l robot rtr1
The authenticity of host 'rtr1 (192.168.240.1)' can't be established.
RSA key fingerprint is <>.
Are you sure you want to continue connecting (yes/no)?
Host rtr1 added to the list of known hosts.
yes
Warning: Permanently added 'rtr1,192.168.240.1' (RSA) to the list of
known hosts.

robot at rtr1's password:
--- JUNOS 9.2R3.5 built 2009-01-15 04:36:25 UTC
{master}
robot at rtr1> #Interacting?

{master}
robot at rtr1> q
show system users
spawn ssh -c 3des -x -l robot show system users
bad spawn_id (process died earlier?)
    while executing
"expect -nobrace -re {(Connection refused|Secure connection [^
]+ refused|Connection closed by)} {
		catch {close}; catch {wait};
		if !$progs {
		   ..."
    invoked from within
"expect {
	    -re "(Connection refused|Secure connection \[^\n\r]+
refused|Connection closed by)" {
		catch {close}; catch {wait};
		if !$progs {
		  ..."
    (procedure "login" line 75)
    invoked from within
"login $router $loginname $passwd $cmethod $cyphertype $identfile"
    ("foreach" body line 62)
    invoked from within
"foreach router [lrange $argv $i end] {
    set router [string tolower $router]
    send_user "$router\n"

    set prompt ">"

    # Figure out usernam..."
    (file "/usr/local/bin/jlogin" line 461)

I do not believe jlogin is modified, however I have modified jrancid
(which isn't even called above), and I didn't have this issue on the
previous version of expect (5.44.1.14) and tcl (8.5.8-2)

Here is my jlogin for reference: http://pastebin.com/FeqYqYPq

Thanks again for helping with this before I have to rollback expect and tcl.

-Josh


On Tue, Mar 29, 2011 at 5:59 PM, john heasley <heas at shrubbery.net> wrote:
> Tue, Mar 29, 2011 at 02:28:14PM -0500, Josh Rogers:
>> Forgot to mention jrancid version:
>>
>> ## $Id: jlogin.in,v 1.69 2009/04/16 21:22:57 heas Exp $
>
> i dont see anything the commit history that should have affected this.
> unless you've modified it in some manner...
>
>> Appreciate the help/direction,
>> Josh
>>
>> On Tue, Mar 29, 2011 at 11:36 AM, Josh Rogers <2010 at tybox.net> wrote:
>> > I was having trouble with rancid reporting 'hung' and lockfiles
>> > remaining, so I installed the patched/hack expect/tcl in hopes of
>> > resolving it.
>
> good.
>
>> > Ever since, I'm seeing the following error below.
>> >
>> > Seems like eof isn't being handled properly when disconnecting, and it
>> > errors out?? Any ideas what is leading to this?
>
> what version of expect?  on what O/S?  the expect_after or the expect after
> the quite should deal with the process exiting; it should receive EOF.  i'd
> suspect a change in expect, perhaps.
>
>> >
>> > $ jlogin -t 120 -c"show chassis clocks;show chassis environment;show
>> > chassis firmware;show chassis fpc detail;show chassis hardware
>> > detail;show chassis routing-engine;show chassis scb;show chassis sfm
>> > detail;show chassis ssb;show chassis feb detail;show chassis feb;show
>> > chassis cfeb;show chassis alarms;show system license;show system
>> > boot-messages;show system core-dumps;show version detail;show
>> > interfaces description;show configuration;show configuration | display
>> > set" rtr2
>> > spawn ssh -c 3des -x -l robot rtr2
>> > <output of show commands>
>> >
>> > {master}
>> > robot at re0.rtr2> quit
>> >
>> > Connection to rtr2 closed.
>> > bad spawn_id (process died earlier?)
>> > ??? while executing
>> > "expect -nobrace {
>> > } { exp_continue } timeout { catch {close}; catch {wait};
>> > ??? ??? ??? ??? ??? ??? ? return 0
>> > ??? ??? ??? ??? ??? ??? } eof { return 0 }"
>> > ??? invoked from within
>> > "expect {
>> > ??? "\n"??? ??? ??? ??? ??? { exp_continue }
>> > ??? timeout??? ??? ??? ??? ??? { catch {close}; catch {wait};
>> > ??? ??? ??? ??? ??? ??? ? return 0
>> > ??? ??? ??? ??? ??? ??? }
>> > ??? eof??? ??? ??? ??? ??? { return 0 }
>> > ??? }"
>> > ??? (procedure "run_commands" line 21)
>> > ??? invoked from within
>> > "run_commands $prompt $command"
>> > ??? ("foreach" body line 68)
>> > ??? invoked from within
>> > "foreach router [lrange $argv $i end] {
>> > ??? set router [string tolower $router]
>> > ??? send_user "$router\n"
>> >
>> > ??? set prompt ">"
>> >
>> > ??? # Figure out usernam..."
>> > ??? (file "/usr/local/bin/jlogin" line 461)
>> >
>> >
>> >
>> > $ expect -v
>> > expect version 5.43.0
>> > $ which tclsh
>> > $ ls -l /usr/bin/tclsh
>> > lrwxrwxrwx 1 root root 23 Nov 29 16:04 /usr/bin/tclsh -> /etc/alternatives/tclsh
>> > $ ls -l /etc/alternatives/tclsh
>> > lrwxrwxrwx 1 root root 23 Mar 29 11:05 /etc/alternatives/tclsh ->
>> > /usr/local/bin/tclsh8.4
>> >
>> >
>> > Section of jlogin that is failing:
>> >
>> > # Run commands given on the command line.
>> > proc run_commands { prompt command } {
>> > ??? global in_proc
>> > ??? set in_proc 1
>> >
>> > ??? send "set cli complete-on-space off\r"
>> > ??? expect -re $prompt? {}
>> > ??? send "set cli screen-length 0\r"
>> > ??? expect -re $prompt? {}
>> >
>> > ??? set commands [split $command \;]
>> > ??? set num_commands [llength $commands]
>> > ??? for {set i 0} {$i < $num_commands} { incr i} {
>> > ??????? send "[lindex $commands $i]\r"
>> > ??????? expect {
>> > ??????????? -re "^\[^\n\r *]*$prompt $" {}
>> > ??????????? -re "^\[^\n\r]*$prompt."??? { exp_continue }
>> > ??????????? -re "(\r\n|\n)"???????????????????? { exp_continue }
>> > ??????? }
>> > ??? }
>> > ??? send "quit\r"
>> > ??? expect {
>> > ??????? "\n"??????????????????????????????????? { exp_continue }
>> > ??????? timeout???????????????????????????????? { catch {close}; catch {wait};
>> > ????????????????????????????????????????????????? return 0
>> > ??????????????????????????????????????????????? }
>> > ??????? eof???????????????????????????????????? { return 0 }
>> > ??? }
>> > ??? set in_proc 0
>> > }
>> >
>> >
>> > Thanks much,
>> > Josh
>> >
>> _______________________________________________
>> Rancid-discuss mailing list
>> Rancid-discuss at shrubbery.net
>> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
>


More information about the Rancid-discuss mailing list