Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
heya,
i've got this script that controls traffic between two boxes with simple iptables statements. it's good when we want to take one site down for testing, but leave the other one up for production stuffs.
each of these boxes holds a handful of sites, and we have a couple of scripts in each site. i figure that there has to be away to make a "meta script"- a menu that serves up a list of site names and, based on the response, performs those scripts, with all the pertinent info for that site stored in a config file.
unfortunately, i haven't done that much scripting. i have my config file written up that has one site per line:
url,ip,sitename,foo...
url,ip,sitename,foo...
url,ip,sitename,foo...concatenating this config and cutting makes it easy to display a list of sites, and i follow it with a prompt: what site do you want to reroute?
question is, what next? based on that answer, how can i pick the right line from the config file to pass along the required parameters? if i grep -i (lotsa lazy typists out there ;) for that site's name, how do i extract the line number? alternatively, i could number each site and make the user enter that number, but i'm still stuck with grabbing the right line.
any ideas or help would be crazy appreciated.

#!/bin/ksh
hostname1 () {
echo "Some meaningful code"
} # END function hostname1
usage () {
echo "Usage $0 hostname"
}if [ $# -eq 1 ] ; then
case $1 in
hostname1 | hostname2 | hostname3 | hostname4 ) $1 ;;
h | -h | --help ) usage ; exit 0 ;;
* ) echo "Invalid command line option." ; usage; exit 4 ;;
esac
else
usage
fi
PS3='host? '
select host in \
"hostname1 " \
"hostname2 " \
"hostname3 " \
"hostname4 " \
"(Q) Quit " ;
do
case $REPLY in
1 | 2 | 3 | 4 ) $host
;;
q | Q | 5 )
break
;;
* )
print 'invalid'
;;
esac
done

![]() |
Changing domains and IP a...
|
Blocking Sent Info to Par...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |