Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The code does something like this: eval spawn $proto $sshopts $username@$host where $proto is either "telnet" or "ssh", and then expects a password prompt, username etc. : catch { expect -re "(assword)|(ser(name)?)|(yes/no)" } however if no username or password prompt is forthcoming - because f.ex. the respective ssh connection is configured to do key-based authentication, then that expect will do nothing at all. The next line will try to access the expect_out variable, fail and trigger an exception, which will be handled by the body of the "if" condition: if { [ catch { set loginbuf "$expect_out(0,string)" } ] } { [...] set loginbuf $expect_out(0,string) Given however, that accessing "expect_out(0,string)" triggered the exception in the first place, accessing that same variable again in the exception handler will trigger the exception again: can't read "expect_out(0,string)": no such element in array while executing "set loginbuf $expect_out(0,string)" ("foreach" body line 35) invoked from within "foreach host $hostlist { ##################### # Login to the host # ##################### if { [ info exist debugfile ] } { if { $FORK == 1 ||..." (file "/home/tpo/bin/ciscocmd" line 444) (note that the line numbers are not correct - due to other causes). Since the variable "loginbuf" in the line "set loginbuf $expect_out(0,string)" doesn't seem to be used anyway, I'm deleting that line of code and thus removing the error/exception displayed above.
- Loading branch information