#!/usr/bin/perl -w # lab 12 solution # ---------------------------------------------------------------------- # variables $lastcmd = 'last -f /var/log/wtmp.1'; $username = 'tuckerm'; $browser = '/usr/bin/firefox'; $url = 'http://meteorology.lyndonstate.edu'; # Parse the output from the unix last or (last -f /var/log/wtmp.1) command and # print out the date and time for each of the logins for your account on # the system. foreach $k (`$lastcmd`) { chomp($k); @items = split(/\s+/, $k); if($items[0] eq $username) { print "$items[0], @items[3..6]\n"; } } # Use the system to run /usr/bin/firefox with the argument of # "http://meteorology.lyndonstate.edu". $ret = system("$browser $url"); # Print the return code to the terminal with some descriptive text if the # return code is 0. if($ret == 0) { print "The browser launched successfully.\n"; }else{ print "There were problems with $browser\n"; } exit;