Ascend Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (ASCEND) TCL Script to program pipelines
> I remember someone on this list a while ago mentioning that they had
> succesfully written a TCL script to program Ascend Pipelines, if you're
> still out there, could I see some chunks of your code? I'm trying to
> accomplish the same thing, and being fairly green at TCL, it's fairly
> difficult ground to tread, not to mention there's no need to reinvent the
> whell.
I have one. It usually works. I designed it to just put in IP address into
a Pipeline via the serial port after which configs could be loaded via tftp
with much more reliability.
I abandoned it because it didn't seem to work all the time. Then I tweaked
it and it works better, but I didn't test it as extensively after that.
It should be able to put that IP in no matter where in the menus the pipe
currently is.
Also I should mention that I too am no TCL programmer so I don't really know
if this is how you're _supposed_ to do things.
(Actually, it uses expect, as you'd expect)
Also it requires the free serial port program "xc" but could easily be
adapted to any other.
pipe_ip -i x.y.z.w "this arg is unused, I wanted to implement it later"
-Phil
#!/bin/sh
PATH=/local/bin:/opt/tcl/bin:$PATH
usage() {
echo "Usage: $0 [-i set_ip_address] command" >&2
exit 1
}
if [ "$1" = "-i" ]; then
shift
ip=$1
if [ -z "$ip" ]; then
usage
fi
shift
fi
command=$1
if [ -z "$command" ]; then
usage
fi
if [ -n "$ip" ]; then
TERM=tty expect -- <<EOT
exp_internal 0
set timeout 10
spawn -noecho xc -l term/a
expect "<XC>"
send "set bps 9600\r"
expect "<XC>"
send "t\r"
expect "TERMINAL"
set max 10
send "\014"
set timeout 2
while {\$max > 0} {
set max [expr \$max - 1]
expect {
timeout {send "\033"; continue}
"Exit and discard" { send "1"; continue }
"Main Edit Menu"
}
break
}
if {\$max == 0} { exit 1 }
send "\014"
set max 10
while {\$max > 0} {
set max [expr \$max - 1]
expect {
timeout { send "\016"; continue }
">20-000" break
">Configure" { send "\016"; continue }
-re ">\[0-9\]\[0-9\]-" { send "\016"; continue }
}
}
if {\$max == 0} { exit 1 }
send "\r"
set timeout 5
expect ">20-100 Connections"
send "\020"
expect ">20-A00"
send "\r"
expect ">Ether options..."
send "\r"
expect ">IP Adrs"
send "\r"
expect "\["
set send_slow {1 .001}
send -s "$ip\r"
set timeout 10
expect "IP Adrs="
send "\033"
expect ">Ether options..."
send "\033"
expect "Exit and accept"
send "2"
sleep 1
send "\030q"
expect "\033\[m"
wait
exit 0
EOT
else
echo "NOTIMP" >&2
fi
++ Ascend Users Mailing List ++
To unsubscribe: send unsubscribe to ascend-users-request@bungi.com
To get FAQ'd: <http://www.nealis.net/ascend/faq>
References: