11-26-2009
shell script that will automatically check if specifed user is log in or not, in 30 seconds
guys I need emergency help with below shell script assignment..am new to shell script
Write a Shell script to automatically check that a specified user is logged in to the
computer.
The program should allow the person running the script to specify the name of the
user to be checked, the frequency in seconds at which the script should check. If a
checking frequency is not specified, it should default to 60 seconds
The script should check for the specified user and if found should output a message
with a “beep” or “bell” sound to the screen stating that the user is logged in. It should
also output a message to a log file stating that the user is logged in and specifying the
date and time.
If the user is not logged in the script should output a message without any “beep”
sound to the screen stating that the user is not logged in.
The script should allow a person running the script to specify the user name on the
command line and optionally, a check frequency in seconds and a third argument “q”
“q” . If “q” is present as a third argument, The script should omit any output to the
screen or “beep” sound but should log to a log file the message stating that the user is
logged in and giving the time.
The command to run the script would be as follows:
checklogin username 30 q where “checklogin” is the script name, “username” is the
name of the user, “30” is the optional frequency to check in seconds, and “q” is the
optional argument to suppress screen output.
The script should check that the number of arguments supplied is between 1 and 3 and
if it is not, should terminate with an error message showing the correct syntax for the
command.
You will be required to make a demonstration in the lab on how your program is
working. You will be required to produce a printed copy of your shell on the same
day. After your demonstration , make a directory in your home directory called
“assignment” and copy your shell script program to it. Give your program a unique
name beginning with your username ‘usernamelinuxshell' Your name, student
number and course you are taking must appear at the top of your program. It is
important to make sure that the program is fully documented.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I am working on a project, which need to constantly watch the process, and check its status, if it was dead, it should be restart automatically.
Please kindly refer me to URL which teach how to write this kind of script, or service.
Thanks. (1 Reply)
Discussion started by: dragondad
1 Replies
2. Shell Programming and Scripting
hi
how can i wait for 5 seconds inside my shell script? 'wait 5' command doesnot seem to be working? (2 Replies)
Discussion started by: gopsman
2 Replies
3. Shell Programming and Scripting
Good day,
I'm new to linux environment...Is there any scripts available for me to check ports (lets say port 80 and 21) through shell with just a single commandline?
Any response is very much appreciated..
thanks (4 Replies)
Discussion started by: arsonist
4 Replies
4. Shell Programming and Scripting
Hi All,
OS:AIX 5.3 64 bits
I would like the below script to send alert mail with the message - "Standby logs falling behind Primary" to xyz@yahoo.com
Script
=====
#!/usr/bin/ksh
#-----------------------------------------------------------------------------
# Use SQL*Plus to query... (1 Reply)
Discussion started by: a1_win
1 Replies
5. Shell Programming and Scripting
Hello friends,
Kindly help me in developing a script that asks user to enter a value and will wait for 5 seconds for the feedback. If there is no answer from the user the script will perform exit or it will continue doing something else
Ex: If yu have a multi OS system i believe while... (3 Replies)
Discussion started by: frozensmilz
3 Replies
6. Shell Programming and Scripting
Hi i have not don anny scripting before so pls answer simple:)
I want to make a shell script that i can use to execute a program on a nother
pc. They are both using CentOS.
The command i use to execute to program from my computer is:
First i open a terminal and write:
#ssh -X gw302 (i... (4 Replies)
Discussion started by: fkildal
4 Replies
7. Shell Programming and Scripting
hi, everyone.
My want to execute the shell script below per 10 seconds
PID=`pgrep java`
if
then
/home/java/java
fi
crontab wouldn't help me.
some one can give me suggestions?thanks
---------- Post updated at 07:29 AM ---------- Previous update was at 07:26 AM ----------
... (6 Replies)
Discussion started by: AKB48
6 Replies
8. Shell Programming and Scripting
Hi Friends,
i am creating a shell script which is accepting file name as input parameter from Java and invoking finacle service.
The service will accpet text file,B2k_session id,etc and upload the text file data in finacle database.
My shell script looks like this:-
#! /bin/ksh... (2 Replies)
Discussion started by: vadlamudy
2 Replies
9. Shell Programming and Scripting
Hi friends,,,
I am running one server on Ubuntu 12.04 LTS 32-bit, some times my pc restarts automatically, with no reason, I have a script to start server which requires root password. in this directory
/myserver/start_server.sh
How can I do this ?
and some scripts I am having that I... (1 Reply)
Discussion started by: Akshay Hegde
1 Replies
10. Shell Programming and Scripting
How to check the user input to be valid using shell script?
The valid input is in the format like as follows.
1. It can only have r,w,x or a hyphen and nothing else.
2. ensure the r, w, x are in the correct order.
for example: rwxr-xr-x is a valid format.
Thanks (5 Replies)
Discussion started by: hyeewang
5 Replies
LEARN ABOUT NETBSD
script
SCRIPT(1) BSD General Commands Manual SCRIPT(1)
NAME
script -- make typescript of terminal session
SYNOPSIS
script [-adfpqr] [-c command] [file]
DESCRIPTION
script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive
session as proof of an assignment, as the typescript file can be printed out later with lpr(1).
If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript.
Option:
-a Append the output to file or typescript, retaining the prior contents.
-c command
Run the named command instead of the shell. Useful for capturing the output of a program that behaves differently when associated
with a tty.
-d When playing back a session with the -p flag, don't sleep between records when playing back a timestamped session.
-f Flush output after each write. This is useful for watching the script output in real time.
-p Play back a session recorded with the -r flag in real time.
-q Be quiet, and don't output started and ended lines.
-r Record a session with input, output, and timestamping.
The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not
set) for the C-shell, csh(1)).
Certain interactive commands, such as vi(1), create garbage in the typescript file. script works best with commands that do not manipulate
the screen, the results are meant to emulate a hardcopy terminal.
ENVIRONMENT
The following environment variable is used by script:
SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most
shells set this variable automatically).
SEE ALSO
csh(1) (for the history mechanism).
HISTORY
The script command appeared in 3.0BSD.
BUGS
script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects.
BSD
October 17, 2009 BSD