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
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...
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...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the purchases and fixed assets business areas. Prepare a 12- to 16-slide presentation describing the purchases and fixed assets business areas. Be sure to incorporate speaker notes as well as appropriate visuals, graphics, fonts, etc. Include any associated risk in these areas. Describe specific internal controls that include authorization of transactions, segregation of duties, adequate records and documentation, security of assets, and independent checks and...
What role could the governance of ethics have played if it had been in existence in...
What role could the governance of ethics have played if it had been in existence in the organization? Assess the leadership of Enron from an ethical perspective. THE FALL OF ENRON: A STAKEHOLDER FAILURE Once upon a time, there was a gleaming headquarters office tower in Houston, with a giant tilted "£"' in front, slowly revolving in the Texas sun. The Enron Corporation, which once ranked among the top Fortune 500 companies, collapsed in 2001 under a mountain of debt...
Discuss ethical issues that can be identified in this case and the mode of managing ethics...
Discuss ethical issues that can be identified in this case and the mode of managing ethics Enron finds itself in this case. How would you describe the ethical culture and levels of trust at Enron? Provide reasons for your assessment. THE FALL OF ENRON: A STAKEHOLDER FAILURE Once upon a time, there was a gleaming headquarters office tower in Houston, with a giant tilted "£"' in front, slowly revolving in the Texas sun. The Enron Corporation, which once ranked among...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT