Re: Fixed BBX Terminal numbers with pseudo ttys

From: Michel Donais (donais@gsig-net.qc.ca)
Date: 04/17/03


From: "Michel Donais" <donais@gsig-net.qc.ca>
Date: Wed, 16 Apr 2003 23:44:55 -0400

Hi Danny,

I was in the same bath last year.

If you upgrade to SCO 5.0.6 there is a function called 'seval' witch can do
what you want.
but if an upgrade is not affordable as for me then:

I found some answers from the list last year.
Take at the following it may be a solution for you.

------------------------------------------------------------------------
Michel Donais" <donais@gsig-net.qc.ca> wrote in message
news:9pps8a$li3$1@milo.basis.com...
> We have a number of PC`S connected to a host via a lan.
>
> Each time a PC login at the host a pseudo tty adress is assigned to the
> connection. Iwant to get fixed adresses so that
>
> T1 always connect to /dev/ttys01
> and so for others stations
>
> Michel

I've got a solution that gives a fixed set of terminal IDs to a specific
user. It's login name specific, rather than workstation specific, but works
well for me.

/usr/bin/bbxgo

#!/bin/sh
# Assign users specific terminals

pid=$$
tid=`cat $HOME/.bbterm`
tty=`tty`

# Search for an unlocked TTY id. Note that I've limited my users
# to 10 simultaneous sessions. You may choose a smaller number.
# The file .bbterm in the users home directory contains the basic
# terminal ID that they will have. If it contains "T01" the user
# will get a terminal ID ranging from "T010" to "T019"
num=0
avail=-1
while [ ${avail} = -1 -a ${num} -lt 10 ]
do
    if [ -f ${HOME}/LCK..${tid}${num} ]
    then
        num=`expr ${num} + 1`
    else
        avail=${num}
    fi
done

if [ ${avail} = -1 ]
then
# This section will startch checking the PIDs in the lockfile
# And find one where the PID is no longer in use. This will
# vary depending on the OS that you use. I'm not going to
# give you my code, because it's not very pretty. :-)
else
    echo ${pid} >> ${HOME}/LCK..${tid}${avail}
fi

# The config.stub contains the setopts, stblen, common printers,
# and other configuration information that remains static.
cat /usr/bbx/config.stub > ${HOME}/config.bbx
echo "alias ${tid}${avail} ${tty} scoansi" >> ${HOME}/config.bbx
BBCONFIG=${HOME}/config.bbx
TERMCAP=/usr/bbx/termcap
export BBCONFIG TERMCAP
# Your command line may vary. I've stripped out the various options,
# and the startup program that I run, as it may not be of use to you.
/usr/bbx/pro5
# Clean up the lockfile
rm ${HOME}/LCK..${tid}${avail}
----------------------------------------------------------------------------
-

>The scripts and advice I have received so far are excellent, except for
>the fact that they all require (as far as I can tell) the IP address or
>machine hostname to only log in once. If they log in again from the same
>IP address or hostname, a duplicate BBTERM will be used.
>

I use a system that assigns based on ttyp number so that each BBTERM is
unique...I use a file (term.pro5) that is in this format

ttypxx<tab>TXX<tab>LXX

Jesus Alvarez uses a math algorithm instead you might like bettter... I add
the Terminal & slave printer to a "standard config.pro5 file" that has
common printers in it.

here is my script pro5.start (that calls tty_id below):
#
#assign in case not in file
BBTERM=T99
BBSLAVE=L99

#rem assign FID(0) based on tty
ttyname=`tty`
ttyname1=\/$ttyname
rm /tmp$ttyname > /dev/null 2>/dev/null
usrname=`logname`
awk -f /usr/bin/tty_id /usr/basis/pro5/term.pro5
. /tmp$ttyname

cat /usr/basis/pro5/config.pro5 > /tmp$ttyname

TRASH="alias "$BBTERM" "$ttyname" term"
echo $TRASH >> /tmp$ttyname

#set up slaves

if [ `expr $TERM : "ansi"` -gt "0" ]
then
TRASH="alias "$BBSLAVE" "$ttyname1" \""$usrname"\" cr,slon=1b5b3569
,sloff=1b5b3469,CPCOLS=255,SPCOLS=255"
echo $TRASH >> /tmp$ttyname
fi

if [ `expr $TERM : "wy60"` -gt "0" ]
then
TRASH="alias "$BBSLAVE" "$ttyname1" \""$usrname"\"
cr,slon=1b6423,sloff=14,CPCOL
S=255,SPCOLS=255"
echo $TRASH >> /tmp$ttyname
fi

if [ `expr $TERM : "4313"` -gt "0" ]
then
TRASH="alias "$BBSLAVE" "$ttyname1" \""$usrname"\"
cr,slon=1b41,sloff=1b42,CPCOL
S=255,SPCOLS=255"
echo $TRASH >> /tmp$ttyname
fi
#do the do

env TERMCAP=/usr/basis/pro5/termcap
usr/basis/pro5/pro5 -q -m512 -c/tmp$ttyname /usr2/pgm/MAIN -

#clean up

rm /tmp$ttyname >/dev/null 2>/dev/null
-------------------------------------------------------------------------
here is tty_id

BEGIN{ FS= OFS = "\t"
        i=1
        xx="BBTERM"
        yy="BBSLAVE"
        "tty" | getline ttynam}
        {while

        getline $0
        if

        print xx "=" $1 "; export " xx > ("/tmp" $2)
        print yy "=" $3 "; export " yy >> ("/tmp" $2)
        i=0
        exit
        }
 }
}
----------------------------------------------------------------------------
------------

It appears lots of people encounter this situation!

The scripts and advice I have received so far are excellent, except for
the fact that they all require (as far as I can tell) the IP address or
machine hostname to only log in once. If they log in again from the same
IP address or hostname, a duplicate BBTERM will be used.

In fact, 50% of my folks will be loggin in from a common machine (terminal
server), so they will all have the same IP address/hostname.

To remedy this situation, all I can think of doing is have the startup
script check an enviroment var (TERMLOC) and set the BBTERM accordingly.
TERMLOC could be determined by the terminal server and passed as
a TERM value (set a bogus term type and parse it in /etc/profile).

Does this sound reasonable?

THanks again for all the responses!

Rick Mills

Frank Anderson <franka@azstarnet.com> wrote:
: We execute the following script on login. It looks up the IP address in
: a file named "aliastable" and assigns a corresponding Tx value.

: PSD=`tty |cut -c6-`

: PIP=`who -x | grep $PSD' ' |cut -c38-`,

: # not on a tcp/ip port, then exit

: if [ "$PIP" != "," ]
: then
: aliases=`cat aliastable|grep $PIP|cut -d, -f 2`
: for i in $aliases
: do
: P=`ps -ef|grep bbx4|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
: fi

: The aliastable file just has IP address a comma and Tx value. If who -x
: returns a machine name instead of an IP name, we use that in the
: aliastable. This is on an SCO system.

----------------------------------------------------------------------------

---
We execute the following script on login.  It looks up the IP address in
a file named "aliastable" and assigns a corresponding Tx value.
PSD=`tty |cut -c6-`
PIP=`who -x | grep $PSD' ' |cut -c38-`,
# not on a tcp/ip port, then exit
if [ "$PIP" != "," ]
then
aliases=`cat aliastable|grep $PIP|cut -d, -f 2`
for i in $aliases
do
P=`ps -ef|grep bbx4|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
fi
The aliastable file just has IP address a comma and Tx value.  If who -x
returns a machine name instead of an IP name, we use that in the
aliastable.  This is on an SCO system.
Rick Mills wrote:
>
> In a Unix setup:
>
> In the pro5 application we use, Open Systemss Accounting Software,
> a lot of defaults for flags throughout the system are based on your
> alias device, which is based on your terminl device, which in the
> case of serial terminals and consoles, are static, but in the case
> of people telneting in or running xterm, are dynamic.
>
> Has anybody come up with a solution for this? Right now my quick hack
> is to set the TERM type to something unique, depending on the terminals
> location, then build a config.bbx on the fly based on your current tty.
>
> Has someone come up with a way to determine a unique identifier for
> the terminal your loggin in from, say the IP address?
>
> Thanks for any help!


Relevant Pages

  • Re: Different thread (Was: Re: suse 9.1 upgrade)
    ... taking that I touched mutt 10 years ago. ... Open few terminals, edit script in one, run test in ... > 2) making a DVD iso from an avi according to ... Put all steps in script. ...
    (alt.os.linux.suse)
  • Re: OSR5: how to find out disabled terminals by authorization subsystem?
    ... address *inside* the TCP startup script to ... terminals and files. ... disabled here and there ("Account is disabled -- see Account ... I found they had no root password set and they wanted it that way ...
    (comp.unix.sco.misc)
  • Re: fgets() equivalent?
    ... TELNET and all telecommunication programs in the annals of computers is both RAW and COOKED. ... In raw mode with echo enabled, if I press A then B then C then enter, I ... We write online and automated hosting server and clients side applications that has dealt with this issues for the past 25+ years and deal with customers across the board. ... Not all early terminals offer command line because that assume some level of intelligence with having a BUFFER to hold the characters. ...
    (microsoft.public.win32.programmer.kernel)
  • OSR5: how to find out disabled terminals by authorization subsystem?
    ... After manually defaulting to the Korn Shell, changing the "intr" code to CTRL-C, going through the install with a broken "Spanish" keyboard map, setting TIMEOUT=20 in /etc/default/boot so the machine starts directly into multi-user mode *and* doesn't stall forever asking the time, configuring a default terminal type so it again stops asking forever, touching ~/.hushlogin to get rid of a full screen worth of copyright notices, manually configuring a sane and informative shell prompt, making root's $HOME something other than "/", and setting the IP address *inside* the TCP startup script to configure in a file to be sourced by said script, incredible!), I can say it is a nice and stable UNIX, although the userland smells a little of old... ... At first, it was a shock with my test users being disabled here and there ("Account is disabled -- see Account Administrator"), and the terminal channels being disabled too. ... About the terminals locking issue, I have found the "ttylock" and "ttyunlock" system commands, which work great. ...
    (comp.unix.sco.misc)
  • Re: OSR5: how to find out disabled terminals by authorization subsystem?
    ... After manually defaulting to the Korn Shell, ... address *inside* the TCP startup script to ... terminals and files. ... disabled here and there ("Account is disabled -- see Account ...
    (comp.unix.sco.misc)