Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

10: 00: 00 Boot-up complete - system now available 10: 03: 06 SIGNON sconnery ON

ID: 3846746 • Letter: 1

Question

10: 00: 00 Boot-up complete - system now available 10: 03: 06 SIGNON sconnery ON tty1 10: 13: 12 SIGNON rmoore ON tty3 10: 18: 02 LPT1 out of paper, please reload 10 23: 02 SIGNOFF sconnery ON tty1 10: 30: 10 DSK1 backup starting 10 33: 06 SIGNOFF rmoore ON tty3 10: 40: 39 SIGNON dcraig ON tty4 10: 42: 34 SIGNON cdalton ON tty2 10: 43: 48 LPT1 paper reloaded - output 003 for cdalton printed 10: 46: 06 SIGNOFF cdalton ON tty2 10: 58: 52 SIGNON pbrosnan ON tty1 10: 58: 06 SIGNON rmoore ON tty2 10: 58: 09 SIGNOFF dcraig ON tty4 10: 58 10 DSK1 backup completed 10: 59: 06 SIGNON dcraig ON tty4 10: 59: 16 DSK2 backup starting 10 59: 12 SIGNOFF rmoore ON tty2 11: 05: 45 SIGNON wallen ON tty6 11: 09: 23 SIGNOFF dcraig ON tty4 11: 11: 38 SIGNOF wallen ON tty6 11: 12: 00 DSK2 backup completed 11: 13: 57 SIGNON rmoore ON tty3 11: 15: 20 SIGNOFF rmoore ON tty3 Who has signed on AT ALL, and how many times each? Something bad happened between 10-11... who was on THEN? What terminals (tty#) has rmoore used?

Explanation / Answer

Code:
#!/usr/bin/perl

use warnings;
use strict;

# script name: boot_report.pl
# variable declaration
my (%users, %uniq_users, %uniq_term);

# variable initialization
%users = %uniq_users = %uniq_term = ();

# opening a file boot.txt for reading
open(FP, "boot.txt") or die "file boot.txt cannot be opened for reading: $!";

# reading each line from the file
while(my $line = <FP>){
   chomp($line);
   # checking how many time each user logged in
   if($line =~ /SIGNON/){
       $line =~ /SIGNON (w+)/;
       $users{$1}++;
   }
   # identifying between 10-11 who are the different users logged in
   if($line =~ /^10/ || $line =~ /^11:00/){
       if($line =~ /SIGNON/){
           $line =~ /SIGNON (w+)/;
           $uniq_users{$1}=0;
       }
   }
   # Fetching different terminals rmoore has logged in
   if($line =~ /SIGNON rmoore/){
       $line =~ /SIGNON rmoore ON (w+)/;
       $uniq_term{$1}=0;
   }
  
}
print " Users signed on AT ALL times and number of times they signed in ";
foreach my $usr(keys %users){
   print $usr, " ", $users{$usr}, " ";
}
print " Users signed in between 10-11 are ";
foreach my $usr(keys %uniq_users){
   print $usr, " ";
}
print " Terminals rmoore has used are ";
foreach my $term(keys %uniq_term){
   print $term, " ";
}
close(FP);

Execution and output:
Unix Terminal> cat boot.txt
10:00:00 Boot-up complete - system now available
10:03:06 SIGNON sconnery ON tty1
10:13:12 SIGNON rmoore ON tty3
10:18:02 LPT1 out of paper, please reload
10:23:02 SIGNOFF sconnery ON tty1
10:30:10 DSK1 backup starting
10:33:06 SIGNOFF rmoore ON tty3
10:40:39 SIGNON dcraig ON tty4
10:42:34 SIGNON cdalton ON tty2
10:43:48 LPT1 paper reloaded - output 003 for cdalton printed
10:46:06 SIGNOFF cdalton ON tty2
10:58:52 SIGNON pbrosnan ON tty1
10:58:06 SIGNON rmoore ON tty2
10:58:09 SIGNOFF dcraig ON tty4
10:58:10 DSK1 backup completed
10:59:06 SIGNON dcraig ON tty4
10:59:16 DSK2 backup starting
10:59:12 SIGNOFF rmoore ON tty2
11:05:45 SIGNON wallen ON tty6
11:09:23 SIGNOFF dcraig ON tty4
11:11:38 SIGNOF wallen ON tty6
11:12:00 DSK2 backup completed
11:13:57 SIGNON rmoore ON tty3
11:15:20 SIGNOFF rmoore ON tty3

Unix Terminal> ./boot_report.pl

Users signed on AT ALL times and number of times they signed in
dcraig 2
sconnery 1
rmoore 3
pbrosnan 1
cdalton 1
wallen 1

Users signed in between 10-11 are
dcraig
rmoore
sconnery
pbrosnan
cdalton

Terminals rmoore has used are
tty2
tty3

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote