Answered step by step
Verified Expert Solution
Question
1 Approved Answer
field will likely be of the form pts(# or pts/## , though there may be variations. If you would like to investigate the last command
field will likely be of the form pts(# or pts/## , though there may be variations. If you would like to investigate the last command more, type man last at the Unix prompt. Problem One of the shortcomings of the last command is that there is no summation or reporting facility to tell someone using the command an overall summary of how long someone has used the system over the course of a month or how many times the person connected. For a company that might charge for hourly usage of their system, it would be helpful if there was a utility that would generate these kinds of basic statistics as well as provide a listing of all logins for a specific account. Solution For this assignment, you'll be writing a program to display summary information about a single users account on the system. Here are the specifications for your program; make sure you read and understand all requirements before proceeding 1. Your program must take one command-line argument, which will be the name of the account to summarize. If no command-line argument is given, display a usage statement and exit the program. You can assume that the account exists, no valiation of this fact is necessary. 2. Your program will then process the output from last and display a summary of that account's activity including the following information: account name, how many logins were executed, and the time in HH:MM format (not DD+HH: MM) Output requirements 1. You must display each login entry, prefaced by a login # (sequential numbers starting at 1). See the final page for a complete example of the output. 2. Make sure your final output follows this formatting, where the time should be in the format HH:MM, where HH and MM (hours and minutes) should both be two digits in length, including leading Os if necessary. The user's full account name, logins and time should each be displayed on separate lines in that order: FULL ACCOUNT_NAME NUMBER_OF_LOGINS TOTAL_TIME_IN_HH:MM Points to Think About The only input into the program will come from the command line argument passed into the program. There won't be any use of the operator in this program. Remember to use use Modern: :Perlin your program. Remember to use the correct shebang line in your program. How will you go about grabbing all of the entries that match and then process them? You may assume that the account provided on the command line is valid and that the account exists. Whether or not that individual has any logins is a condition that should be handled appropriately. You will need to make sure that you handle accounts that have the D+HH:MM format listed for their logins. To get a listing of accounts that match this, use the Unix grep command like this: [Loki] last grep + This will give you a listing of accounts that have entries in the your program. D+HH:MM format that you can then test in Make sure to handle if the command-line argument that is provided is longer than 8 characters. last only records the first 8 characters of a user's account, so you'll need to handle if someone provides for the command-line argument and locate only entries from the output of bartsimpson last bartsimp Grading Notes . You must have an Honor Pledge on file for the course for the program to be graded You must have complete header documentation as outlined in the Course Materials section of Blackboard. You must use at least one regular expression in your program, since this assignment is meant to reinforce the material that's recently been covered in class. Points will be deducted if your program generates warnings with the use Modern: :Perl; pragma to a maximum of 5 points, 1 point per warning See the output at the end of this assignment or run the sample program on Loki for an actual example Your hours and minutes must be in two-digit format, in other words, single digits should have a leading 0 to pad the results, like 00:00 Make sure to stop the program if no command-line argument is given or too many command line arguments are provided. Provide a usage statement if no command-line argument is given, and make sure to use $0 in your usage statement to produce the correct output. Do not process partial command-line arguments, such as if the program were run with ./lastsummary.pl art, it shouldn't bring up a summary of all logins that contain the text art The only listings that should match would be a username of art , so no listings for bartsimp, for instance, should show up Do not convert the time summary to days, hours and minutes. Make sure your total time output is only in total hours and minutes . Do not use the last account format of last or last account| grep account to get just information for a particular user. Your program will not be graded if you use either of these methods to obtain your user list. One of the goals of this program is to practice matching with regexes. Your output capture statement should look like this Perl my @lastoutput-last; Sample Program Run username@Loki:$ lastsummary joe smith Usage: lastsummary login Sample Program Run username@Loki$ lastsummary Usage: lastsummary login Sample Program Run username@Loki:$ lastsummary noone Here is a listing of the logins for noone: Here is a summary of the time spent on the system for noone: noone 00:00 Sample Program Run username@Loki $ lastsummary rfulkerson Here is a listing of the logins for rfulkerson: 1. rfulkers pts/3 2. rfulkers pts/7 3. rfulkers pts/5 4. rfulkers pts/3 5. rfulkers pts/1 6. rfulkers pts/6 7. rfulkers pts/3 pki174b-01.ist.u Tue Sep 7 09:49 stil1 logged in ip72-206-101-146 Mon Sep 6 20:26 21:18 (00:51) ip72-206-101-146 Mon Sep 6 20:24 21:18 (00:53) vulcan.ist.unoma Sat Sep 4 19:51 20:09 (00:18) ip72-206-101-146 Fri Sep 307:37-21:29 (13:51) 137.48.177.164 Thu Sep 2 11:54 13:17 (01:23) pki174b-01. st.u Thu Sep 2 09:26-11:48 (02:22) Here is a summary of the time spent on the system for rfulkerson: rfulkerson 19:38 field will likely be of the form pts(# or pts/## , though there may be variations. If you would like to investigate the last command more, type man last at the Unix prompt. Problem One of the shortcomings of the last command is that there is no summation or reporting facility to tell someone using the command an overall summary of how long someone has used the system over the course of a month or how many times the person connected. For a company that might charge for hourly usage of their system, it would be helpful if there was a utility that would generate these kinds of basic statistics as well as provide a listing of all logins for a specific account. Solution For this assignment, you'll be writing a program to display summary information about a single users account on the system. Here are the specifications for your program; make sure you read and understand all requirements before proceeding 1. Your program must take one command-line argument, which will be the name of the account to summarize. If no command-line argument is given, display a usage statement and exit the program. You can assume that the account exists, no valiation of this fact is necessary. 2. Your program will then process the output from last and display a summary of that account's activity including the following information: account name, how many logins were executed, and the time in HH:MM format (not DD+HH: MM) Output requirements 1. You must display each login entry, prefaced by a login # (sequential numbers starting at 1). See the final page for a complete example of the output. 2. Make sure your final output follows this formatting, where the time should be in the format HH:MM, where HH and MM (hours and minutes) should both be two digits in length, including leading Os if necessary. The user's full account name, logins and time should each be displayed on separate lines in that order: FULL ACCOUNT_NAME NUMBER_OF_LOGINS TOTAL_TIME_IN_HH:MM Points to Think About The only input into the program will come from the command line argument passed into the program. There won't be any use of the operator in this program. Remember to use use Modern: :Perlin your program. Remember to use the correct shebang line in your program. How will you go about grabbing all of the entries that match and then process them? You may assume that the account provided on the command line is valid and that the account exists. Whether or not that individual has any logins is a condition that should be handled appropriately. You will need to make sure that you handle accounts that have the D+HH:MM format listed for their logins. To get a listing of accounts that match this, use the Unix grep command like this: [Loki] last grep + This will give you a listing of accounts that have entries in the your program. D+HH:MM format that you can then test in Make sure to handle if the command-line argument that is provided is longer than 8 characters. last only records the first 8 characters of a user's account, so you'll need to handle if someone provides for the command-line argument and locate only entries from the output of bartsimpson last bartsimp Grading Notes . You must have an Honor Pledge on file for the course for the program to be graded You must have complete header documentation as outlined in the Course Materials section of Blackboard. You must use at least one regular expression in your program, since this assignment is meant to reinforce the material that's recently been covered in class. Points will be deducted if your program generates warnings with the use Modern: :Perl; pragma to a maximum of 5 points, 1 point per warning See the output at the end of this assignment or run the sample program on Loki for an actual example Your hours and minutes must be in two-digit format, in other words, single digits should have a leading 0 to pad the results, like 00:00 Make sure to stop the program if no command-line argument is given or too many command line arguments are provided. Provide a usage statement if no command-line argument is given, and make sure to use $0 in your usage statement to produce the correct output. Do not process partial command-line arguments, such as if the program were run with ./lastsummary.pl art, it shouldn't bring up a summary of all logins that contain the text art The only listings that should match would be a username of art , so no listings for bartsimp, for instance, should show up Do not convert the time summary to days, hours and minutes. Make sure your total time output is only in total hours and minutes . Do not use the last account format of last or last account| grep account to get just information for a particular user. Your program will not be graded if you use either of these methods to obtain your user list. One of the goals of this program is to practice matching with regexes. Your output capture statement should look like this Perl my @lastoutput-last; Sample Program Run username@Loki:$ lastsummary joe smith Usage: lastsummary login Sample Program Run username@Loki$ lastsummary Usage: lastsummary login Sample Program Run username@Loki:$ lastsummary noone Here is a listing of the logins for noone: Here is a summary of the time spent on the system for noone: noone 00:00 Sample Program Run username@Loki $ lastsummary rfulkerson Here is a listing of the logins for rfulkerson: 1. rfulkers pts/3 2. rfulkers pts/7 3. rfulkers pts/5 4. rfulkers pts/3 5. rfulkers pts/1 6. rfulkers pts/6 7. rfulkers pts/3 pki174b-01.ist.u Tue Sep 7 09:49 stil1 logged in ip72-206-101-146 Mon Sep 6 20:26 21:18 (00:51) ip72-206-101-146 Mon Sep 6 20:24 21:18 (00:53) vulcan.ist.unoma Sat Sep 4 19:51 20:09 (00:18) ip72-206-101-146 Fri Sep 307:37-21:29 (13:51) 137.48.177.164 Thu Sep 2 11:54 13:17 (01:23) pki174b-01. st.u Thu Sep 2 09:26-11:48 (02:22) Here is a summary of the time spent on the system for rfulkerson: rfulkerson 19:38
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started