Question

Write a shell script called userMonitor.sh that checks each minute and reports on who logs in...

  1. Write a shell script called userMonitor.sh that checks each minute and reports on who logs in and who logs out. Please ignore multiple logins by the same user.
  2. Run in unix with screenshot

Homework Answers

Answer #1

Hi,

#!/usr/bin/ksh

typeset -i SINCE=${1:-1}

date '+%Y +%m %d %H %M' | read year month day hour min

(( min -= SINCE ))

(( min < 0 )) && { (( min += 60 )) ; (( hour -= 1 )) }

(( hour < 0 )) && { (( hour += 24 )) ; (( day -= 1 )) }

(( day <= 0 )) && {

(( month -= 1 ))

(( month <= 0 )) && { (( month=12 )) ; (( year -= 1 )) }

day=$(cal $month $year | tr '\n' ' ' | awk '{print $NF}')

}

ts5=$(printf "%02d%02d%02d%02d" $month $day $hour $min)   

LANG=C who -s |

awk -v ts5="$ts5" -F '[ \t:]*' '

function to_timestamp(month, day, hour, min) {

m = index("_,jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec,", "," tolower(month) ",")/4;

return sprintf("%02d%02d%02d%02d", m, day, hour, min);

}

to_timestamp($3, $4, $5, $6) >= ts5

'

$

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
The first script you need to write is login.sh, a simple script that you might run...
The first script you need to write is login.sh, a simple script that you might run when you first log in to a machine. We'll expand this script later, but for now it should include your name, username, hostname, current directory, and the current time. Here is some sample output to help guide you. Note that the bolded lines that start with "[user@localhost ~]$" are the terminal prompts where you type in a command, not part of the script. Of...
Finally, write a script named word_counts.sh that prints out how many words are on each line...
Finally, write a script named word_counts.sh that prints out how many words are on each line of standard input, as well as the total number of words at the end. The script should take no arguments. Instead, the script must work by reading every line of standard input (using a while loop) and counting the number of words on each line separately. The script is intended to work with standard input coming from a pipe, which will most often come...
write a script named print_lines.sh that uses head and tail together to print out a specific...
write a script named print_lines.sh that uses head and tail together to print out a specific set of lines from a file. The script should take three arguments: the line number to start at, the line number to stop at, and the file to use. Here's an example run: [user@localhost ~]$ print_lines.sh 7 10 /etc/passwd shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt mail:x:8:12:mail:/var/spool/mail:/sbin/nologin operator:x:11:0:operator:/root:/sbin/nologin [user@localhost ~]$ In this example, the script prints line 7 through 10 (inclusive) of the /etc/passwd file. Your script must do...
Save your select statements as a script. Place the semicolon at the end of each SQL...
Save your select statements as a script. Place the semicolon at the end of each SQL statement. Please number your select statements from 1 to 8 in your script and comment out each number. Include your name and student number as a comment at the top of your script. The name of the script has to be Assignment1_JohnSmith. Instead of JohnSmith use your First Name and Last Name. Upload your script trough Blackboard. Use SQL Developer to create the My...
I did already posted this question before, I did get the answer but i am not...
I did already posted this question before, I did get the answer but i am not satisfied with the answer i did the code as a solution not the description as my solution, so i am reposting this question again. Please send me the code as my solution not the description In this project, build a simple Unix shell. The shell is the heart of the command-line interface, and thus is central to the Unix/C programming environment. Mastering use of...
JAVA PROGRAMMING: Write a program called TimeSymbolTables that creates three symbol tables, each of a different...
JAVA PROGRAMMING: Write a program called TimeSymbolTables that creates three symbol tables, each of a different implementation. Each symbol table will contain as a key a word read from a text file and as a value the number of times that word occurs in the text file. Have the program fill the first symbol table with these counts, keeping track of how long that takes using a Stopwatch object. It then does the same thing with the second symbol table....
Problem 1 (Defining products and Creating a Menu) Write a program called a2_p1.py that asks a...
Problem 1 (Defining products and Creating a Menu) Write a program called a2_p1.py that asks a shop owner for product information and creates a menu system that allows customers to purchase multiple products of varying quantities. The program should start by asking the shop owner’s name (string) and company name (string). Next it should ask for three (3) products (strings), their prices (int – not ideal, but for now we will keep it this way), and the number of products...
In java create a dice game called sequences also known as straight shooter. Each player in...
In java create a dice game called sequences also known as straight shooter. Each player in turn rolls SIX dice and scores points for any sequence of CONSECUTIVE numbers thrown beginning with 1. In the event of two or more of the same number being rolled only one counts. However, a throw that contains three 1's cancels out player's score and they mst start from 0. A total of scores is kept and the first player to reach 100 points,...
Note: Do not use classes or any variables of type string to complete this assignment Write...
Note: Do not use classes or any variables of type string to complete this assignment Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along...
In the case below please answer the following 4- 6 pages 1. State the ethical issues...
In the case below please answer the following 4- 6 pages 1. State the ethical issues 2. State the legal issues 3. Discuss the options/debate the issues 4. Discuss extra info needed to make decision Rina Cummings has worked three 12-hour shifts every week at Amazon’s gargantuan New York City warehouse, called JFK8, on Staten Island since it first began operations in late 2018. As a sorter on the outbound ship dock, her job is to inspect and scan a...