Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!sdd.hp.com!mips!daver!genco!rad From: rad@genco.bungi.com (Bob Daniel) Newsgroups: comp.unix.questions Subject: Re: determining port id Message-ID: <586@genco.bungi.com> Date: 21 Mar 91 18:25:46 GMT References: <1991Mar19.171708.18628@wciu.EDU> Reply-To: rad@genco.bungi.com (Bob Daniel) Organization: Gentry & Assoc. Excelsior Springs, MO Lines: 36 In article <1991Mar19.171708.18628@wciu.EDU> george@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.