troubleshooting Question

perl solaris logged in script

Avatar of atom_jelly
atom_jellyFlag for United States of America asked on
Unix OSPerlScripting Languages
3 Comments1 Solution981 ViewsLast Modified:
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.

#!/usr/bin/perl
#
use Time::Local;
#
$sec=59;
$min=59;
$hours=23;
$day=31;
$month=11;
$year=109;
#
$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.


Thanks.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros