Avatar of atom_jelly
Flag for United States of America asked on

perl solaris logged in script

okay I found this perl script then I name is epoch.pl I want to use this script to tell me how long someone has been logged in. Look at my example below. I need help. Thanks.

use Time::Local;
$current = time();
print "$current\n";

(exec /export/home/reports/epoch.pl;last –a) |awk '(NR==1){n=$1;next}/still /{u=$1;printf("/usr/ucb/echo -n %s-;exec /export/home/reports/epoch.pl "%s %s %s %s\" +%s-%%s\n",%u,$3,$4,$5,$6,n) ; }'|sh| awk -F"-" ' {printf("env TZ=GMT printf " user %s  logged in for %d days, %d hours, %d minutes and %d seconds\n", $1, $2-$3)}’|sh

I want to see

user gumby has been logged in for HOURS Minutest and Seconds.

Unix OSPerlScripting Languages

Avatar of undefined
Last Comment

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Hi ozo,

I meant to leave out the /usr/local/bin/date not supposed to use that. But my output  is supposed to look like this with a perl script.

User gumby is logged in for 00 hours 00 minutes and 00 seconds.

bash-3.00# last  -a | perl -MDate::Parse -lane '/still /&&printf"user %s has been logged in for %d hours, %d minutes and %d seconds\n",$F[0],($s=time-(str2time "@F[3,4,5]"))/3600,$s%3600/60,$s%60'
Can't locate Date/Parse.pm in @INC (@INC contains: /usr/perl5/5.8.4/lib/sun4-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/sun4-solaris-64int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_pe
rl /usr/perl5/vendor_perl/5.8.4/sun4-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl .).
BEGIN failed--compilation aborted.

Oh baby thats good!!!!!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck