[rancid] Re: [PATCH] Fortinet RANCID Patches
Daniel G. Epstein
dan at rootlike.com
Wed May 23 00:50:19 UTC 2007
Oops, missed a typo in the fnlogin.diff file. Corrected version
attached.
--
A boast of "I have beens," | Daniel G. Epstein
quoted from foolscap tomes, | Audio Engineer
is a shadow brushed away |
by an acorn from an oak tree | Rootlike Technologies, Inc.
or a salmon in a pool. | http://www.rootlike.com/
GnuPG public keys available from http://pgp.mit.edu/
-------------- next part --------------
--- nlogin 2007-05-22 17:46:58.000000000 -0500
+++ fnlogin 2007-05-22 19:45:15.000000000 -0500
@@ -1,7 +1,5 @@
#! /usr/local/bin/expect --
##
-## $Id: nlogin.in,v 1.32 2006/12/05 16:50:52 heas Exp $
-##
## rancid 2.3.2a6
## Copyright (C) 1997-2006 by Terrapin Communications, Inc.
## All rights reserved.
@@ -23,7 +21,10 @@
# The login expect scripts were based on Erik Sherk's gwtn, by permission.
# Netscreen hacks implemented by Stephen Gill <gillsr at yahoo.com>.
#
-# nlogin - netscreen login
+# FortiOS 2.x hacks implemented by Daniel G. Epstein <dan at rootlike.com>.
+# Tue May 22 17:41:04 CDT 2007 - dan at rootlike.com
+#
+# fnlogin - Fortinet login
#
# Most options are intuitive for logging into a netscreen firewall.
#
@@ -386,9 +387,13 @@
global in_proc
set in_proc 1
- send "set console page 0\r"
+ # Disable output paging.
+ send "config system console\r"
+ send "set output standard\r"
+ send "end\r"
expect -re $prompt {}
+
# Is this a multi-command?
if [ string match "*\;*" "$command" ] {
set commands [split $command \;]
@@ -399,7 +404,7 @@
expect {
-re "\[\n\r]+" { exp_continue }
-re "$prompt" {}
- -gl "--- more ---" { send " "
+ -gl "--More--" { send " "
exp_continue
}
}
@@ -409,7 +414,7 @@
expect {
-re "\[\n\r]+" { exp_continue }
-re "$prompt" {}
- -gl "--- more ---" { send " "
+ -gl "--More--" { send " "
exp_continue
}
}
@@ -442,7 +447,9 @@
set firewall [string tolower $firewall]
send_user "$firewall\n"
- set prompt {-> }
+ # FortiOS 2.x prompts can end in either '#' or '$'
+ set prompt "\[#\\$]"
+
# Figure out passwords
if { $do_passwd || $do_enapasswd } {
@@ -496,15 +503,16 @@
continue
}
- # we are logged in, now figure out the full prompt
+ # we are logged in, now figure out the full prompt based on what the device sends us.
send "\r"
expect {
-re "\[\r\n]+" { exp_continue; }
- -re "^(.+$prompt)" { set junk $expect_out(0,string);
- # if it has HA (high avail), the prompt will
- # be "something-(.)->"
- regsub -all "\[\]\)\(\[]" $junk {\\&} prompt;
- }
+ -re "^(.+$prompt)" { set junk $expect_out(0,string); }
+ if {[$junk = "(^\\$ $)"]} {
+ set prompt $junk;
+ } else {
+ if {[$junk = "(^# $)"]} { set prompt $junk ; }
+ };
}
if { $do_command } {
@@ -512,7 +520,10 @@
continue
}
} elseif { $do_script } {
- send "set console page 0\r"
+ # Disable output paging.
+ send "config system console\r"
+ send "set output standard\r"
+ send "end\r"
expect -re $prompt {}
source $sfile
close
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20070522/bfcc3457/attachment.bin
More information about the Rancid-discuss
mailing list