General
cancel
Showing results for 
Search instead for 
Did you mean: 

disable direct login - only su allowed

Asif_8
Regular Advisor

disable direct login - only su allowed


We have an application user, and we want normal users to logon the system with their own names and su to application user.

I am using C Shell and I am using following scripts for ksh shell is working fine but not
c shell

ME=$(who am i|awk '{print $1}')
grep -q "^${ME}:" /etc/disallowed
if [ $? = 0 ]
then
echo "$ME cannot login directly. Login with your own id and then su - $ME"
read
exit
fi



3 REPLIES
Dennis Handly
Acclaimed Contributor

Re: disable direct login - only su allowed

This is why you don't use the scummy C shell.

$() syntax is the same as ``.
if [ $? = 0 ] should be replaced in ksh by:
if [ $? -eq 0 ]

For scummy C shell, you use $status.
Asif_8
Regular Advisor

Re: disable direct login - only su allowed


thanks following line add in /etc/csh.login

set ME=$(who am i|awk '{print $1}')
grep -q "^${ME}:" /etc/disallowed
if [$status -eq 0]
then
echo "$ME cannot login directly. Login with your own id and then su - $ME"
exit
endif
but not working in c shell
Dennis Handly
Acclaimed Contributor

Re: disable direct login - only su allowed

>set ME=$(who am i|awk '{print $1}')

As I said: $() syntax is replaced by ``.