- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script help please
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2002 05:00 AM
01-31-2002 05:00 AM
What I am trying to do is to limit logins so that users that like to walk around to different pc's and telnet from different IP addresses, will be prevented from doing so.
I want to limit their logins if they are already logged in from another ip address.
I have a problem with a 'fi' but I it has me.
here is the script:
_______________
if [ -x "/usr/bin/whoami" ]
then
WHOAMI=`whoami`
if [ "$WHOAMI" = "root" -o "$WHOAMI" = "nickd" ]
then
:
else
IPLIST=`who -u|tr -s " "|cut -d" " -f8`
THISIP=`who -um | tr -s " " | cut -d" " -f8`
LOGCOUNT=0
for IP_ADDY in `echo $IPLIST` ; do
if [ "${IP_ADDY}" -eq "${THISIP}" ]; then
((LOGCOUNT = LOGCOUNT +1 ))
echo $LOGCOUNT
if [ $LOGCOUNT -gt 1 ] then
echo "You are already logged on in more than one place"
exit
fi
here is the script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2002 05:15 AM
01-31-2002 05:15 AM
Re: script help please
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2002 05:20 AM
01-31-2002 05:20 AM
Re: script help please
If you are going to limit logins why check for ip's
You can prevent a user from logging in multiple times by
placing the following lines in the user's .profile:
# Limit number of logins allowed
Times_allowed=2
Time_in=`who | grep $LOGNAME | wc -l`
if [ $Time_in -gt "$Times_allowed" ]
then
echo "$LOGNAME is already logged in $Times_allowed times!"
exit
exec /bin/login
fi
chmod 444 and chown root .profile
If the user attempts to login while that login name is already in
use, the user will get logged out again. A limited number of multiple
logins can be allowed by changing the times_allowed to the acceptable
number of logins.
This should also be ok in the /etc/profile.
Whever they login from they come through these scripts.
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2002 05:22 AM
01-31-2002 05:22 AM
Re: script help please
The script that you posted is actually missing three 'fi's and a 'done'.
I think that this bit should read:
((LOGCOUNT = LOGCOUNT +1 ))
fi
done
You also need two fi's at the end to close:
if [ "$WHOAMI" = "root" -o "$WHOAMI" = "nickd" ]
and
if [ -x "/usr/bin/whoami" ]
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2002 05:23 AM
01-31-2002 05:23 AM
Re: script help please
You have one "done" and a few "fi" statements missing, and the line:
if [ "${IP_ADDY}" -eq "${THISIP}" ]; then
should be:
if [ "${IP_ADDY}" = "${THISIP}" ]; then
=====================================
if [ -x "/usr/bin/whoami" ]
then
WHOAMI=`whoami`
fi
if [ "$WHOAMI" = "root" -o "$WHOAMI" = "nickd" ]
then
:
else
IPLIST=`who -u|tr -s " "|cut -d" " -f8`
THISIP=`who -um | tr -s " " | cut -d" " -f8`
LOGCOUNT=0
for IP_ADDY in `echo $IPLIST` ; do
if [ "${IP_ADDY}" = "${THISIP}" ]; then
((LOGCOUNT = LOGCOUNT +1 ))
echo $LOGCOUNT
if [ $LOGCOUNT -gt 1 ] ; then
echo "You are already logged on in more than one place"
exit
fi
fi
done
fi
=====================================
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 10:16 AM
02-08-2002 10:16 AM
Re: script help please
your script is close, but there is a "then" that is not matched.
??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 10:29 AM
02-08-2002 10:29 AM
Re: script help please
Did you cut-and-paste Robin's script? -- it's fine.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 10:33 AM
02-08-2002 10:33 AM
Re: script help please
Yes I copied Robin's script and I get an error mesg:
Syntax error: `then` is not matched.
??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 10:41 AM
02-08-2002 10:41 AM
Re: script help please
I thought this might save some emails from going around.
Much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 10:45 AM
02-08-2002 10:45 AM
Re: script help please
#!/usr/bin/csh
set username = `whoami`
# If display not set, get IP and set
if($?DISPLAY == 0) then
# Check for multiple logons of same user name. Warn if found.
if(`finger -R | grep $username | awk '{print $NF}' | sort -u | wc -w` > 1) then
echo "ERROR: User $username logged in on multiple terminals."
echo "Can't determine IP address where you are logged in."
exit 1
endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2002 11:48 AM
02-08-2002 11:48 AM
SolutionOK, it looks like you dropped a 'fi' at line number 163.
Add 'fi' so the last part reads:
# Change the backup tape
if [ -r /tmp/changetape ]
then echo "\007\nYou are the first to log in since backup:"
echo "Please change the backup tape.\n"
rm -f /tmp/changetape
fi
fi # <<<--- THIS WAS MISSING !!!
# Leave defaults in user environment.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2002 04:14 AM
02-10-2002 04:14 AM
Re: script help please
Nickd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2002 10:32 AM
02-20-2002 10:32 AM
Re: script help please
The last script that I received from James works,except for one problem.
It locks everyone out completely except for the exception list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2002 11:11 AM
02-20-2002 11:11 AM
Re: script help please
James is right in that there is an unmatched if in your script.
I think the place to stick it, though is at the end of the section where you are testing for VUE environment stuff, right before the test for logins.
Counting if s and fi s to ensure they balance is a pain, but not being able to log in is worse......
hth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2002 11:46 AM
02-20-2002 11:46 AM
Re: script help please
I did include that last fi, and the script works, but not as designed.
It locks everyone out, except the users listed on the exception list.
I have attached the profile for your review.
Thanks for your time,
Nd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 08:16 AM
02-26-2002 08:16 AM
Re: script help please
Should I re-post this?
Nickd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 08:47 AM
02-26-2002 08:47 AM
Re: script help please
# Limit logins to 2
USER=`logname`
LOGINS=`who -H | grep -c $USER`
### Debug info...
print "Current logins: $LOGINS"
### Search $USER for exceptions
ALLOWTHESE="rbudaric|pics|tladouce|nickd"
echo $USER | egrep "$SKIPTHESE"
rc=$?
if [ $rc -eq 1 ] ### If this user is not part of the exception list
then
if [ $LOGINS -gt 2 ]
then echo The maximum # of logins is 2
echo and you have already reached your limit.
echo
echo Nickd ext 278 Kanata
echo Pausing for 10 seconds
touch /tmp/$USER
/usr/sbin/sendmail $USER sleep 10
#sendmail $USER exit
fi
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 08:50 AM
02-26-2002 08:50 AM
Re: script help please
Thanks for the tip, but I think we are missing the second part of my problem.
I also want to restrict users from using more than one computer (IP address) unless they are in the exception list.
I couldn't tell for sure, but I don't think your script does that, does it?
Nickd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2002 09:35 AM
02-26-2002 09:35 AM
Re: script help please
I've tested this in my own .profile and it appears to work. Let me know...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2002 10:36 AM
03-07-2002 10:36 AM
Re: script help please
Works like a charm.
The only problem is, all the files that it spawns in /tmp.
Does the script need those mailmesg files or can I delete them?
Thanks,
nickd