[rancid] Minor fix/update for hlogin ( and *login?).
Per-Olof Olsson
peo at chalmers.se
Wed Feb 27 07:47:30 UTC 2013
Hello
Testing some minor update for hlogin (rancid 2.3.8).
Sometimes I use hlogin to login to switches but get the session filtered by
hpuifilter. A bit hard to work with that output. I think this helps.
rancid at host bin]$ diff -c hlogin.in_ORG hlogin.in
*** hlogin.in_ORG 2013-01-21 07:05:47.357345221 +0100
--- hlogin.in 2013-02-27 07:56:51.332898135 +0100
***************
*** 328,336 ****
regexp {(telnet|ssh)(:([^[:space:]]+))*} $prog command suffix junk port
if [string match "telnet*" $prog] {
if {"$port" == ""} {
! set retval [ catch {spawn hpuifilter -- telnet $router} reason ]
} else {
! set retval [ catch {spawn hpuifilter -- telnet $router $port} reason ]
}
if { $retval } {
send_user "\nError: telnet failed: $reason\n"
--- 328,344 ----
regexp {(telnet|ssh)(:([^[:space:]]+))*} $prog command suffix junk port
if [string match "telnet*" $prog] {
if {"$port" == ""} {
! if { $do_command || $do_script } {
! set retval [ catch {spawn hpuifilter -- telnet $router } reason ]
! } else {
! set retval [ catch {spawn telnet $router} reason ]
! }
} else {
! if { $do_command || $do_script } {
! set retval [ catch {spawn hpuifilter -- telnet -- $router $port}
reason ]
! } else {
! set retval [ catch {spawn telnet -- $router $port} reason ]
! }
}
if { $retval } {
send_user "\nError: telnet failed: $reason\n"
***************
*** 346,352 ****
if {"$identfile" != ""} {
set cmd "$cmd -i $identfile"
}
! set retval [ catch {eval spawn hpuifilter -- [split "$cmd -c $cyphertype -x -l
$user $router" { }]} reason ]
if { $retval } {
send_user "\nError: $cmd failed: $reason\n"
return 1
--- 354,364 ----
if {"$identfile" != ""} {
set cmd "$cmd -i $identfile"
}
! if { $do_command || $do_script } {
! set retval [ catch {eval spawn hpuifilter -- [split "$cmd -c
$cyphertype -x -l $user $router" { }]} reason ]
! } else {
! set retval [ catch {eval spawn [split "$cmd -c $cyphertype -x -l $user
$router" { }]} reason ]
! }
if { $retval } {
send_user "\nError: $cmd failed: $reason\n"
return 1
Testing to set negative port number to telnet shows that it don't work on RHlinux
(from "man cloginrc" " Example: add method * {ssh} {telnet:-3000} {rsh}").
Tested "add method <hostname> {telnet:-23}"
-----------------------
$ telnet <hostname> -23
telnet: invalid option -- '2'
Usage: telnet [-8] [-E] [-L] [-S tos] [-a] [-c] [-d] [-e char] [-l user]
[-n tracefile] [-b hostalias ] [-r]
[host-name [port]]
--------------------
I have to add "--" to telnet args in hlogin, "telnet -- $router $port"
or used positive port number and put
----------------------
DEFAULT
mode character
----------------------
or
----------------------
<hostname>
mode character
----------------------
in ~/.telnetrc
Is telnet special for RHlinux or update needed for telnet in all *login scripts
and/or add some notes in man page for cloginrc about ~/.telnetrc?
/Peo
----------------------------------------------------------
Per-Olof Olsson Email: peo at chalmers.se
Chalmers tekniska högskola IT-service
Hörsalsvägen 5 412 96 Göteborg
Tel: 031/772 6738 Fax: 031/772 8660
----------------------------------------------------------
More information about the Rancid-discuss
mailing list