Trailblazer configuration awk script
Craig Leres
leres at ace.ee.lbl.gov
Tue Nov 21 19:43:27 AEST 1989
Here's an awk script I wrote to munge the configuration output of my
Trailblazer T2500's so that I could more easily restore a config (when
doing rom upgrades, for example). My awk is vanilla SunOS 3.5.
Typically, I tell the modem:
atz1
atn?
atz2
atn?
And then slurp up the output and stick it on a file. To setup a modem
as per the configuration stored in the file, I run the awk script over
it and stuff the commands at the modem.
It assumes you have new enough roms such that registers that are
different than the factory defaults are identified with a colon (e.g.
"S51:005").
If you add any features, I'd appreciate getting a copy (but if you
convert it to perl, please do not send it to me because I DON'T LIKE
SPAM!)
Craig
------
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# tb.awk
# This archive created: Tue Nov 21 00:29:18 1989
export PATH; PATH=/bin:$PATH
echo shar: extracting "'tb.awk'" '(1711 characters)'
if test -f 'tb.awk'
then
echo shar: will not over-write existing file "'tb.awk'"
else
sed 's/^X//' << \SHAR_EOF > 'tb.awk'
X# @(#) $Header: tb.awk,v 1.3 89/11/21 00:25:57 leres Exp $ (LBL)
X#
X# tb.awk - Convert Trailblazer configuration output to commands
X#
X
XBEGIN {
X # Force us to start with profile 1
X profile = 0
X
X # Command to blast configuration back to the stone ages
X printf "ats255=0 &f &w1 &w2\n"
X
X line = ""
X nline = ""
X
X linefmt = "at%s &w%d\n"
X savefmt = "at&w%d\n"
X}
X
X/^[aT][tT]/ {
X # Ignore dialogue
X continue
X}
X
X/^OK/ {
X # Ignore dialogue
X continue
X}
X
X/ Version/ {
X # Output anything we've stored.
X if (line != "") {
X printf linefmt, line, profile
X line = ""
X }
X if (nline != "") {
X printf savefmt, profile
X nline = ""
X }
X
X # Alternate between profiles (hopefully we only get a total of two)
X if (profile == 1)
X profile = 2
X else
X profile = 1
X
X # Initialize configuration to this profile
X printf "atz%d\n", profile
X
X # Output the special registers (too hard to only do changed ones)
X i = index($0, " Version")
X printf linefmt, substr($0, 0, i), profile
X continue
X}
X
X/^N/ {
X # Output stored register line
X if (line != "") {
X printf linefmt, line, profile
X line = ""
X }
X j = index($0, ":")
X if (j > 0) {
X l = length($0)
X nline = substr($0, 0, j - 1) "=" substr($0, j + 1, l)
X printf "at%s\n", nline
X }
X continue
X}
X
X/^S/ {
X # Handle S registers
X num = split($0, a)
X for (i = 1; i <= num; i++) {
X s = a[i]
X j = index(s, ":")
X if (j > 0) {
X l = length(s)
X if (length(line) + l >= 72 - 5) {
X printf linefmt, line, profile
X line = ""
X } else if (line != "")
X line = line " "
X line = line substr(s, 0, j - 1) "=" substr(s, j + 1, l)
X }
X }
X continue
X}
X
X{
X # Chud
X printf "# %s\n", $0
X continue
X}
X
XEND {
X if (line != "")
X printf linefmt, line, profile
X if (nline != "")
X printf savefmt, profile
X}
SHAR_EOF
if test 1711 -ne "`wc -c < 'tb.awk'`"
then
echo shar: error transmitting "'tb.awk'" '(should have been 1711 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
More information about the Alt.sources
mailing list