[K12OSN] Re: Need script help for fl_teachertool

Eric Harrison eharrison at mail.mesd.k12.or.us
Wed May 3 04:38:53 UTC 2006

On Tue, 2 May 2006, Robert Arkiletian wrote:

> On 5/2/06, Eric Harrison <eharrison at mail.mesd.k12.or.us> wrote:
>> Thus anything with ".0.0." in it will match "0.0".
>> This should work better for you:
>>         getent hosts | grep ^`echo $DISPLAY | sed -e 's/:/ /g'\   | awk 
>> '{print $1}'` | cut -f1
> Thanks Eric, interesting and clear explanation. But sitting at the
> server this returns nothing. I need something. works for me.
> Explained below.

It is supposed to return nothing, since returning "" happened to
be a bug ;-)

How about running the command and checking to see if there was a value
returned. If not, they are logged into the server so you should use the
IP addresses of the server?

 	# /sbin/ifconfig  | grep "inet addr:" | cut -d: -f2 | cut -d" " -f1


>> BUT, this is all very convoluted. It has the feeling of approaching a 
>> problem
>> in the wrong way.  What is the context of what you are working on? There may
>> be a cleaner solution.
> thanks to you and Jim giving me tips at LinuxFest I was able to speed
> up fl_teachertool amazingly. It's FAST now :)
> Using the -n like you suggested
> netstat -t -e -n | grep :6000 | sed -e 's/:/ /g' | awk '{print $9,$6}'
> | sort | uniq
> works perfect and like lightning compared to having a dns lookup for
> every line of output. So now I have ip's instead of hostnames of all
> clients. This is fine BUT I use the $DISPLAY env variable to omit the
> terminal machine a teacher (running fl_TT) is sitting at (for obvious
> reasons like logging yourself out) So I have to omit the teacher
> terminal by omitting the ip which matches the $DISPLAY.  That's why
> works. Since none of the terminals have this ip none are
> omitted (which is what I want when someone runs fl_TT from the
> server).
> This line
> cat /etc/hosts | grep `echo $DISPLAY | cut -d: -f1` | cut -f1
> works when running fl_TT on a terminal but not properly if the teacher
> runs fl_TT on the server (as you noticed)
> Long story short. Basically I just need fl_teachertool to figure out
> the ip of the terminal which it's running on and if running on the
> server it needs to give me an ip which none of the terminals would
> have eg. or so no match to omit is found. The
> only method of determining the ip of the terminals I know of is to get
> the $DISPLAY var and find it's corresponding ip in /etc/hosts (since I
> can't assume ws222.ltsp is If you know an easier way
> I'd love to hear it.
> Hope this is not as clear as mud.
> --
> Robert Arkiletian
> Fl_TeacherTool http://fltk.org/links.php?V269
> C++ GUI tutorial http://fltk.org/links.php?V19

More information about the K12OSN mailing list