Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The following code is in Shell Script/ Bash Script. I need this to be in Perl Script. The output should look like: #!/bin/bash if [[

The following code is in Shell Script/ Bash Script. I need this to be in Perl Script.

The output should look like: image text in transcribed

#!/bin/bash

if [[ $1 == '' ]]

then

echo "usage: ./lastsummary "

exit

fi

out=$(last | grep $1)

c=1

echo "Here is a listing of the logins for $1:"

echo ""

oneline=""

hours=0

minutes=0

while read -r line

do

echo " $c. $line"

c=$((c+1))

#oneline=$line

read -ra el

f=${el[-1]}

s=${el[-1]}

if [[ ${f:2:1} == '+' ]]

then

fh=${f:3:2}

fm=${f:6:2}

else

fh=${f:1:2}

fm=${f:4:2}

fi

hours=$((hours+fh))

minutes=$((minutes+fm))

done

if [[ $minutes -ge 60 ]]

then

h=$((minutes/60))

hours=$((hours+h))

minutes=$((minutes%60))

fi

echo ""

echo "Here is the summary of the time spent on the system for $1:"

echo ""

echo $1

echo $c

echo "$hours::$minutes"

Sample Program Run Here is a listing of the logins for noone Here is a summary of the time spent on the system for noone 00:00 Sample Program Rurn usernanegLoki:-$ lastsunnary 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 (88:51) ip72-286-191-146 Mon Sep 6 20:24 21:18 (08:53) vulcan.ist.unoma Sat Sep 4 19:51 28:89 (08:18) ip72-206-191-146 Fri Sep 3 07:37 21:29 (13:51) 137.48.177.164 Thu Sep 2 11:54 13:17 (81:23) pkil74b-91. ist.u Thu Sep 209:26-11:48 (e2:22) Here is a sumary of the time spent on the system for rfulkerson 19:38 Sample Program Run Here is a listing of the logins for noone Here is a summary of the time spent on the system for noone 00:00 Sample Program Rurn usernanegLoki:-$ lastsunnary 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 (88:51) ip72-286-191-146 Mon Sep 6 20:24 21:18 (08:53) vulcan.ist.unoma Sat Sep 4 19:51 28:89 (08:18) ip72-206-191-146 Fri Sep 3 07:37 21:29 (13:51) 137.48.177.164 Thu Sep 2 11:54 13:17 (81:23) pkil74b-91. ist.u Thu Sep 209:26-11:48 (e2:22) Here is a sumary of the time spent on the system for rfulkerson 19:38

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago