1833758 Members
2715 Online
110063 Solutions
New Discussion

HELP*** HP-UX Script

 
Edi Simanjuntak
Occasional Contributor

HELP*** HP-UX Script

Dear All,

Anyone can help me about how to restricted open session (telnet) for each user.
I want to allow 2 session only for each user.
Any tools or script solve my problem.
Many thanks in advance for your help.

Rgds,
ES
5 REPLIES 5
Tim D Fulford
Honored Contributor

Re: HELP*** HP-UX Script

I'm assuming this will go into /etc/profile, (though it could go into .profile)

usr=$(whoami)
case $usr in

# Put special users here
root|informix) echo "Special users go on in"
;;

*) if [ $(who | grep $usr | wc -l) -gt 2 ]
then
echo "You are already logged in. Your sessions are"
who | grep $usr
exit
fi
;;
esac

Give it a whirl

Tim
-
Frank Li
Trusted Contributor

Re: HELP*** HP-UX Script

Hi,

No apparently solution , but you can modify the /etc/profile to meed your requirement :

Add the following to you /etc/profile :
-=-=-=-=-=
trap "" 1 2 3

nuser=`who | grep $LOGNAME | wc -l`;
if test "$nuser" -gt 2
then
exit
fi

trap 1 2 3

-=-=-=-=-=-=

It should work.
Hope this solve your question.




Hi Friend
Victor_5
Trusted Contributor
Jordan Bean
Honored Contributor

Re: HELP*** HP-UX Script

It seems that everyone has the same basic idea. A scheme I've used is to first determine if the account has a uid greater than 100. If so, check to see if the username appears in a bypass list. If not, see if the user is already on twice. At the end of /etc/profile, I used

if [ $(id -u) -gt 100 ]; then
if ! $(grep -q $LOGNAME /etc/bypass); then
if [ $(wc -h $LOGNAME | wc -l) -gt 2 ]; then
cat <<.

I'm sorry. You're already on twice. Goodbye!

.
fi
fi
fi

Naturally, we've only accounted for users of the posix, korn, and bourne-again shells.
Jordan Bean
Honored Contributor

Re: HELP*** HP-UX Script

I forgot to 'exit' after the rude message.