Solaris Shell Scripting

Hi,

Want to know, is there any way to restrict a Solaris user to Single Login. Means a particular user can login once and if he or someone else tries to login with his ID then a message displayed "user already logged in" and denies his attempt.

Regard,

Jeet

sh,ksh,bash login shell? Put the following to the user's .profile

logins=`\who -u | \awk '$1==u&&$NF!~/^\(?:[0-9]+\..\)?$/{++s}END{print s+0}' u="$USER"`
[ $logins -gt 1 ] && exec echo "user already logged in"

tcsh,csh login shell? Put the following to the user's .login

set logins=`\who -u | \awk '$1==u&&$NF!~/^\(?:[0-9]+\..\)?$/{++s}END{print s+0}' u="$USER"`
if ( $logins > 1 ) exec echo "user already logged in"