Ascend Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (ASCEND) Script to change multiple MAX configs?



On Tue, 24 Mar 1998, Stephen Chen wrote:

> With the recent discovery of UDP port 9 problem, we had to install the
> filter on dozens of MAXes twice because the first filter published was
> incorrect.  Is there a easier way to make configuration changes over
> several MAXes?  I've thought about writing a Perl script which duplicates
> key strokes, but there's got to be something better.
> 
> Any suggestion is greatly appreciated.

	I made an expect script that did all the key strokes, unfortunatly
it only works with 5.0Ap33 or 5.0Ap36 AND you have to be running code from
the tk.m40 file.
	If you run code from any other file, it may screw up the system
big time. The script is attached, usage is bug $host, where $host is the
Max40xx name.


	Regards


Ps. Expect/perl scripts are a pain to write for Ascend equipment since you
    have to use arrows and etc.

Cyril Jaouich [CJ837]
---------------------
ACC DATA OPERATIONS EASTERN CANADA/US
-------------------------------------
#!/usr/local/bin/expect -f

set timeout 10
set a 0
set tel "telnet password here"
set full "full access password here"
foreach host $argv {
if 0==$a {
set pop $host
set a 1
} else {
set line $host
}
}

spawn telnet $host

expect "Enter password: "
send "$tel\r"
expect "System"
send  ""
expect "Password"
send "p"
expect "Full"
send "\[A\[C"

#\[A
#up

#\[C
#left

#\[B
#down



#\[D
#right

# Erase/backspace 
expect "Enter"
send "$full\r"
##### BEGIN #####
expect "System"
send "\[A\[A\[A"
expect "Ethernet"
send "\n"
expect ">90-100 Connections"
send "\[B\[B\[B\[B"
expect ">90-500 Filters"
send "\n\n"
expect ">Name="
send "\nUDP Attack\n"
expect ">Name="
send "\[B\n"
expect ">In filter"
send "\n"
expect {
        ">Valid=Yes" {
        send "\[B"   
        }
        ">Valid=No" {
        send "\r\[B"
        }
}

expect {
	">Type=GENERIC" {
        send "\r\[B"
	}
	">Type=IP" {
        send "\[B"   
	}
}
send "\[B\n"   

expect {
        ">Forward=No" {
        send "\[B"
	}
	">Forward=Yes" {
        send "\r\[B"
	}
}
expect ">Src Mask"
send "\n0.0.0.0\n"
send "\[B"
expect ">Src Adrs"
send "\n0.0.0.0\n"
send "\[B"
expect ">Dst Mask"
send "\n0.0.0.0\n"
send "\[B"
expect ">Dst Adrs"
send "\n0.0.0.0\n"
send "\[B"
expect ">Protocol"
send "\n17\n"
send "\[B\[B\[B"
expect {
        ">Dst Port Cmp=None" {
        send "\n\n\[B"
	}
	">Dst Port Cmp=Less" {
        send "\n\[B"
	}
	">Dst Port Cmp=Eql" {
        send "\[B"
	}
	">Dst Port Cmp=Gtr" {
        send "\n\n\n\n\[B"
	}
	">Dst Port Cmp=Neq" {
        send "\n\n\n\[B"
	}
}
expect ">Dst Port #"
send "\n9\n"
expect ">Dst Port #"
send "\[D\[D2"

expect ">In"
send "\[B"
expect ">"
send "\n"
expect {
        ">Valid=Yes" {
        send "\[B"   
        }
        ">Valid=No" {
        send "\r\[B"
        }
}

expect {
	">Type=GENERIC" {
        send "\[B"
	}
	">Type=IP"	{
        send "\n\[B"   
	}
}
send "\n"   

expect {
        ">Forward=No" {
        send "\n\[B"
	}
	">Forward=Yes" {
        send "\[B"
	}
}
expect "Offset="
send "\n0\n"
send "\[B"
expect "Len"
send "\n0\n"
send "\[B"
expect "Mask"
send "\n0000000000000000\n"
send "\[B"
expect "Value"
send "\n0000000000000000\n"
send "\[B"
expect {
        ">Compare=Equals" {
        send "\[B"
	}
        ">Compare=Equals" {
        send "\n\[B"
	}
}
expect {
        ">More=No" {
        send "\[B"
	}
        ">More=Yes" {
        send "\n\[B"
	}
}
send "\[D\[D2"
expect ">Out"
send "\[D\[B"

#### OUTPUT FILTERS ####
expect ">Output filters"
send "\n"
expect ">Out filter"
send "\n"
expect {
        ">Valid=Yes" {
        send "\[B"   
        }
        ">Valid=No" {
        send "\r\[B"
        }
}

expect {
	">Type=GENERIC" {
        send "\r\[B"
	}
	">Type=IP"	{
        send "\[B"   
	}
}
send "\[B\n"   

expect {
        ">Forward=No" {
        send "\[B"
	}
	">Forward=Yes" {
        send "\r\[B"
	}
}
expect ">Src Mask"
send "\n0.0.0.0\n"
send "\[B"
expect ">Src Adrs"
send "\n0.0.0.0\n"
send "\[B"
expect ">Dst Mask"
send "\n0.0.0.0\n"
send "\[B"
expect ">Dst Adrs"
send "\n0.0.0.0\n"
send "\[B"
expect ">Protocol"
send "\n17\n"
send "\[B\[B\[B"
expect {
        ">Dst Port Cmp=None" {
        send "\n\n\[B"
	}
	">Dst Port Cmp=Less" {
        send "\n\[B"
	}
	">Dst Port Cmp=Eql" {
        send "\[B"
	}
	">Dst Port Cmp=Gtr" {
        send "\n\n\n\n\[B"
	}
	">Dst Port Cmp=Neq" {
        send "\n\n\n\[B"
	}
}
expect ">Dst Port #"
send "\n9\n"
expect ">Dst Port #"
send "\[D\[D2"

expect ">Out filter"
send "\[B"
expect ">"
send "\n"
expect {
        ">Valid=Yes" {
        send "\[B"   
        }
        ">Valid=No" {
        send "\r\[B"
        }
}

expect {
	">Type=GENERIC" {
        send "\[B"
	}
	">Type=IP"	{
        send "\n\[B"   
	}
}
send "\n"   

expect {
        ">Forward=No" {
        send "\n\[B"
	}
	">Forward=Yes" {
        send "\[B"
	}
}
expect "Offset="
send "\n0\n"
send "\[B"
expect "Len"
send "\n0\n"
send "\[B"
expect "Mask"
send "\n0000000000000000\n"
send "\[B"
expect "Value"
send "\n0000000000000000\n"
send "\[B"
expect {
        ">Compare=Equals" {
        send "\[B"
	}
        ">Compare=Equals" {
        send "\n\[B"
	}
}
expect {
        ">More=No" {
        send "\[B"
	}
        ">More=Yes" {
        send "\n\[B"
	}
}
send "\[D\[D2"
expect ">Output"
send "\[D\[D2"
expect ">90-501"
send "\[D"
expect ">90-500"
send "\[B\[B\[B\[B\[B\[B\n"
expect ">Module"
send "\[B\n"
expect ">IP"
send "\[B\[B\[B\[B\[B\[B"
expect ">Filter"
send "\n1\n"
expect ">Filter"
send "\[D\[D2"
expect ">90-B00 Mod Config"
#### Getting to Answer PROFILE ####
send "\[B"
expect ">90-100"
#send "\[D"
send "\[B\[B\[B\[B\[B\[B"
#### ANSWER PROFILE ####
expect "90-700"
send "\n"
expect ">Use"
send "\[A\[A\n"
expect ">RIP"
send "\[B"
expect ">Data"
send "\n1\n"
expect ">Data"
send "\[D\[D2"
expect ">90-700"
#interact
send  ""
send "c"
expect "closed"



References: