Restriction for more than one user

How do l restrict more than one users on a multiple programming environment using the c shell profile. That is if a user is log-on on one terminal the system should be able to prompt a message if the users attempt to log on on another terminal. I user openserver 5.0.4 with dummy terminals, and also intelligent workstation using telnet.

Thanks

Kayode

Here's one you could try:

Restrict number of logins allowed for a user

To restrict multiple logins, place the following lines in the users .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

Then chmod 444 and chown root .profile

Just an FYI on the script above - you will never get the chance to "exec /bin/login" if you exit right before.
It shouldn't matter though - when you logout, another should be spawned.

I didn't write that program, so I don't know for sure, but isn't it just forcing the user to logoff (exit command) and then providing another prompt so that some different user could potentially log on?

Hello! Mr oombera

Thanks for the script. However, l made a mistaken of the type of shell script l have on my system. It is Bourne Shell and not C shell.
I tried running the above script on my system but l am prompt with the following errors:

-rsh : who : not found
-rsh : grep : not found
-rsh : wc : not found
-rsh : test : argument expected

Does it mean that C Shell script can't run on Bourne Shell script?

Thanks

Kayode

oombera, inittab and getty takes care of respawning the login prompt after a user exits, so you dont have to worry about providing another login prompt.

norsk hedensk, I understand what you're saying... maybe the script was written for an older system? maybe the programmer has a habit of including unneeded code? :slight_smile:

kayode, I'm not sure why it's giving you those errors.. try including #!/bin/sh at the top of the script.. other than that, those commands are pretty common on all unices.. unless they weren't installed on your system somehow..

Can you go to a command prompt and type any of them? For example:
who | grep <your_user_name>
wc <some_file>

Hi oombera

Thanks the script really work l mean perfectly.

Thanks

kayode