KB#00221-Unix scripts to dynamically assign a FID(0)
Title:
Unix scripts to dynamically assign a FID(0)
Description:
# @(#) SetClient Addition to /etc/profile to set environment variable
# @(#) CLIENT to name of telnet client machine
# @(#) Invoke as: . /usr/bin/SetClient
tty=`who -mx |awk '{print $2}'|grep ttyp`
if [ -n "$Tty" ] then
CLIENT=`who -mx |awk '{print $6}'`
echo $CLIENT else
CLIENT="" fi
export CLIENT
This script depends on 2 things. The 'who -m' command works. (SCO OpenServer), and there are entries for the various machines in /etc/hosts. Otherwise, who -m returns the internet address.
Once CLIENT is set, create a table like:
T0 Winnie
T1 Tigger
T2 Opus
etc. Then do:
set grep $CLIENT /usr/bbx/table XxXx
if [ "$1" = "XxXx ] then
echo "$CLIENT not found in table" else
BBTERM=$1
export BBTERM fi
These are "bare bones", but you get the idea.
=================================================
The above method works great, but there is also another method. This is similar to the method used with FacetTerm. Create a script that is executed just before starting BBx like this:
. /usr/bin/ipbbterm
/usr/pro5/pro5 -----the rest of the arguments----
The script:
# /usr/bin/ipbbterm - script that sets BBTERM based on IP address and the table
# file referenced on 'aliases=' line
# table format:
# field 1=IP address, field 2=TerminalID to use for Alias, field 3=remark
# table fields are tab delimited
# multiple, unique aliases are allowed for each unique IP address, being assigned on a first
# available basis
PSD=`tty |cut -c6-10`
PIP=`who -x | grep $PSD |cut -c38-`
# table file search
aliases=`cat /usr/dsamod/aliastable|grep $PIP|cut -f 2`
# the P='`ps -ef|grep pro5|grep t$i' '` line searches the process status report for pro5
# if it finds a pro5 then it searches that line(s) for the letter 't' followed by whatever
# is in the variable $i followed by a space. (If $i isn't set then it looks for 't' )
for i in $aliases do
P=`ps -ef|grep pro5|grep t$i' '`
if [ "$P" = "" ]
then
BBT=$i
break
fi done
if [ "$BBT" = "" ] then
echo "NO sessions available for address $PIP"
echo "Return to exit:\c"
read q
exit else
BBTERM=$BBT
export BBTERM fi
A sample of the 'aliastable' file:
204.75.156.22 T10 Winnie the Pooh
204.75.156.22 T11 Winnie the Pooh
204.75.156.22 T12 Winnie the Pooh
204.75.156.150 T18 Tigger the Tiger
204.75.156.150 T19 Tigger the Tiger
204.75.156.150 T20 Tigger the Tiger
204.75.156.19 T4 Opus the Penguin
204.75.156.19 T5 Opus the Penguin
204.75.156.19 T6 Opus the Penguin
As you see, this also allows for multiple sessions in bbx for the same workstation(IP address).
All entries in config.bbx look like this:
alias T0 /dev/tty term k0
alias T1 /dev/tty term k0
and so on.
Last Modified: 09/28/2001 Product: PRO/5 Operating System: Unix
BASIS structures five components of their technology into the BBx Generations.