Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 24th, 2004, 05:18 AM
guythomas guythomas is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: Worcestershire, England
Posts: 35 guythomas User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Script to prevent multiple logons

Scenario

User logs in at Workstation 1
User then tries to logon at Workstation 2 while still logged in at Workstation 1.

What I am looking for is a script which will test if a user is already logged on elsewhere, and if so, display a message saying "Already logged on at <Station Name>" and then terminate the current logon.

Guy Thomas
__________________
Guy Thomas
Ezine http://computerperformance.co.uk/ezine/newsletter_subs.htm

Reply With Quote
  #2  
Old April 15th, 2004, 11:32 PM
murugesan murugesan is offline
Dinesh_P_V
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: India
Posts: 256 murugesan New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 11 h 38 m
Reputation Power: 0
Send a message via Yahoo to murugesan
guythomas
You can achive it by adding the following in .bashrc file present in the user's home directory
This is for a particular user.

Code:
tt=`whoami`
tt=`who | grep $tt | wc -l`
if [ $tt -gt 1 ]
then
        echo Already logged on. Please press Enter to exit.
        read
        exit
fi
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
unset tt

FYI

The code
Code:
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

would be already in .bashrc file.

Here you have some problem. Some times ( seldom ) the who command will display as if the user has logged in even if they were not logged in. This happens ( this too very rarely ) when the user terminal abruptly terminates.
So it not advisible to set this for a root user.

Last edited by murugesan : April 15th, 2004 at 11:51 PM.

Reply With Quote
  #3  
Old April 19th, 2004, 01:09 AM
murugesan murugesan is offline
Dinesh_P_V
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: India
Posts: 256 murugesan New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: 11 h 38 m
Reputation Power: 0
Send a message via Yahoo to murugesan
A slight modification in the script

Code:
stty erase '^C'
stty intr ''
tt=`whoami`
tt=`who | grep $tt | wc -l`
if [ $tt -gt 1 ]
then
        echo Already logged on. Please press Enter to exit.
        read
        exit
fi
stty intr '^C'
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
unset tt


The previous code will allow the user to login when Ctrl C is pressed instead of Enter while loggin in.

Regards,
Murugesan

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > Script to prevent multiple logons


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway