### Copyright (C) 1995-1997 Jesper K. Pedersen ### This program is free software; you can redistribute it and/or modify ### it under the terms of the GNU General Public License as published by ### the Free Software Foundation; either version 2 of the License, or ### (at your option) any later version. ### ### This program is distributed in the hope that it will be useful, ### but WITHOUT ANY WARRANTY; without even the implied warranty of ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ### GNU General Public License for more details. ### ### You should have received a copy of the GNU General Public License ### along with this program; if not, write to the Free Software ### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. proc watch {} { # watch Desc "Here you can set up a watch on who is logging in or out"\ "of the machine you are sitting on." ShortDesc "Configuration of 'user watch'" ############################### Widgets ############################## Int time \ -text "Interval to check for login/logout's" \ -textafter "(minutes.)" \ -default 10 Entry user -text user Entry tty -text "tty" ExtEntry watch \ -text "User to watch for on your machine" \ -entries user tty ### who FillOutElm n \ -text "User who logged in or out" \ -show {print "\[user\]"} \ -save {print "%n"} FillOutElm a \ -text "observed action" \ -show {print "\[action\]"} \ -save "print %a" FillOutElm l \ -text "observed terminal" \ -show {print "\[tty\]"} \ -save "print %l" FillOutElm M \ -text "Full hostname" \ -show {print "\[Host\]"} \ -save "print %M" FillOutElm m \ -text "partial hostname" \ -show {print "\[Host\]"} \ -save "print %m" FillOut who \ -text "Format of the watch string" \ -entries n a l M m \ -default "%n% has %a% %l% from %m%."\ -listbox:width 50 \ -packFrame:anchor c ################################ Help ################################ Help time \ "This is the interval in which the shell should check for"\ "logins / logouts on the machine." Help user \ "This is a user name like george, or `any', to check for all users" Help tty \ "This is the tty to check for users on, or `any' to check on"\ "all tty of the current machine." Help watch \ "This gives you the possibility to check for users who"\ "log in or out on the machine you are sitting at." Help n \ "This is the name of the current user, who logged in" \ "or logged out of the machine." Help a \ "This is the observed action (logged in or logged out.)" Help l \ "This is the terminal (tty) which the user logged in or out on." Help M \ "This is the full host name of the remote host the login/logout"\ "came from (local if the local was from the local host.)" Help m \ "This is the host name of the remote host, up to the first dot"\ "the login/logout came from (local if the local was from the"\ "local host.) The full host name is printed if it is an IP address or"\ "an X-window display" Help who \ "This is the formating string for the watch information." ############################## Page End ############################## PageEnd { set count 0 forevery watch { incr count if {$user == "" && $tty == ""} continue if {$user == "" || $tty == ""} { error "either user or tty where blank in line $count" } } if {$time == ""} { error "Entry with text:\"Interval to check for login/logout's\" is empty" } } ################################ Save ################################ Save { ########## watch ########## set list "" forevery watch { if {$user == "" && $tty == ""} continue lappend list $user $tty } if {$list != "" || $generateDefault} { if {$list == ""} { print "unset watch" } else { print "set watch = ($time $list)" } } ########## who ########## if {$who != "%n has %a %l from %m." || $generateDefault} { if {$who == {%n has %a %l from %m.}} { print "unset who" } else { print "set who = \"$who\"" } } } }