Michael Tatarinov wrote:
easier :)
#!/bin/sh
eval `ntpq -c 'rv 0 ss_uptime'`
let secs=$(($ss_uptime%60))
let mins=$(($ss_uptime/60%60))
let hours=$(($ss_uptime/3600%24))
let days=$(($ss_uptime/86400))
echo "${days}d ${hours}h ${mins}m ${secs}s"
I'm positive perl can do this in a line or two, while running on both
*ix and Win* platforms...
I'll try with '123456' as the number of seconds of uptime:
C:\>perl -e "use POSIX qw/strftime/;printf('%d %s',123456/86400,
strftime('%H:
%M:%S',gmtime(123456)))"
1 10:17:36
I.e. that seems to work, but I haven't found a way for the built-in
strftime() to output number of days, so I had to handle that separately. :-(
Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
_______________________________________________
questions mailing list
[email protected]
http://lists.ntp.org/listinfo/questions