Results 1 to 1 of 1
Hi All,
I was asked to write a shell script. Below is the description.
1. Develop a shell script in Linux to control the number of times a user is ...
- 02-27-2007 #1Just Joined!
- Join Date
- Feb 2007
- Posts
- 3
Validate login sessions..
Hi All,
I was asked to write a shell script. Below is the description.
1. Develop a shell script in Linux to control the number of times a user is allowed to log into the system concurrently:
Requirements:
a. Create a login permission file .maxlogin that defines the maximum number of concurrent login sessions for each user.
An example login permission file:
marcel 3
tux 2
natika 4
This file indicates that the user marcel is allowed to log into the system for at most 3 times concurrently.
b. Write a shell script file logtest to
i) Check whether the current user is root or a regular user;
ii) If the user is root, display a welcome message for this super user;
iii) If the user is a regular user, do the following (iv & vii):
iv) Count the number of concurrent login sessions opened by the current user;
v) Compare the number of concurrent login sessions with the allowable login limit defined in .maxlogin;
(vi) Display a welcome message if it is under the allowable login limit;
(vii) Display a warning message and EXIT if it exceeds the allowable login limit.
Hint: you may use finger command to get the number of concurrent login sessions for a particular user.
Note: if logtest is added to /etc/profile, you can control the number of concurrent sessions a user is allowed to open.
Attached are the files that I used..
I attached the output also..."command not found" errors...
~/Final$ sh chk_ses.sh keith
NO OF SESSION ALLOWED IS 4
YOUR ARE TRYING TO OPEN SESSION NO 0
]: command not foundif[0
: command not found
: command not found then
=0]: command not foundf[
: command not found:
: command not found: then
WELCOME TO keith HOME DIR
: command not found: else
CONNECTION REFUSED AS MAX SESSION LIMIT IS 4
: no such pidine 16: kill:
: command not found: fi
: command not found: else
WELCOME TO keith HOME DIR
: command not found: fi


Reply With Quote