determining port id
Bob Daniel
rad at genco.bungi.com
Fri Mar 22 04:25:46 AEST 1991
In article <1991Mar19.171708.18628 at wciu.EDU> george at wciu.wciu.edu (George Peavy) writes:
>I'm still learning shell programming, and have hit a snag that, so far, I
>haven't been able to figure out.
>
>Here's what's happening: I'm writing a menu program that, among other things,
>allows a user to select the option of up/downloading files to/from a PC.
>Since I also have terminals attached, I want to disallow this option unless
>the user is working from a port known to have a pc attached to it.
>
>
> who am i | awk '{ print $2 }'
>
>The question is, how do I get this information into a place where I can
>test the value? Is there a simpler way than my use of awk?
This is how I do it...
device=`tty`
port=`basename $device`
if [ "$port" = "ttyXX" ]
then
...
fi
or instead of 'if'....
case $port in
ttyX1) foo1;;
ttyX2) foo2;;
etc) fooX;;
esac
______
The ` is accent marks, not single quotations. I'm using AT&T SysV 3.2.3 so
this should work for you.
More information about the Comp.unix.questions
mailing list