eval and let, I have never come across those guys before! The man page only comes with some scanty information on builtin commands and zilch about let.
I am off to ask the wonderful wizard of Oz how to do shell scripting properly! Thanks so much :) From: Michael Tatarinov [mailto:[email protected]] Sent: Tuesday, 21 February 2012 7:12 PM To: Mark C. Stephens Cc: [email protected] Subject: Re: [ntp:questions] ntp version 4.2.7p257-o 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" 2012/2/21 Mark C. Stephens <[email protected]<mailto:[email protected]>> [root@NTP ~]# cat ntpd-uptime #!/usr/local/bin/bash _time=`ntpq -c sysstats | grep uptime | awk 'BEGIN{FS=" "}{print $2}'` _days=`printf "scale=0;$_time / 86400\n" | bc -l` _hours=`printf "scale=0;($_time / 3600) - ($_days * 24)\n" | bc -l ` _minutes=`printf "scale=0;($_time / 60) - ($_days * 1440) - ($_hours * 60)\n" | bc -l` _seconds=`printf "scale=0;$_time %% 60\n" | bc -l` printf "${_days:-0}D ${_hours:-0}H " printf "${_minutes:-0}M ${_seconds:-0}S\n" [root@NTP ~]# ./ntpd-uptime 1D 7H 56M 23S > -----Original Message----- > From: Dave Hart [mailto:[email protected]<mailto:[email protected]>] > Sent: Tuesday, 21 February 2012 1:53 PM > To: Mark C. Stephens > Subject: Re: [ntp:questions] ntp version 4.2.7p257-o > > yes > > On Tue, Feb 21, 2012 at 02:35, Mark C. Stephens > <[email protected]<mailto:[email protected]>> > wrote: > > What is the measurement, seconds? > > > > Sent from my iPad > > > > On 21/02/2012, at 12:36, "Dave Hart" <[email protected]<mailto:[email protected]>> > > wrote: > > > >> On Tue, Feb 21, 2012 at 00:54, Mark C. Stephens <marks@non- > stop.com.au<http://stop.com.au>> wrote: > >>> A feature request: NTPD uptime in hh:mm:ss? > >> > >> C:\bin\dig>ntpq -c sysstats pool-test.ntp.org<http://pool-test.ntp.org> > >> uptime: 497426 > >> sysstats reset: 497426 > >> packets received: 407367100 > >> current version: 303585168 > >> older version: 90119976 > >> bad length or format: 13653619 > >> authentication failed: 279276 > >> declined: 1046 > >> restricted: 25269 > >> rate limited: 54916625 > >> KoD responses: 3132859 > >> processed for time: 23864 > >> > >> Cheers, > >> Dave Hart > >> > > _______________________________________________ questions mailing list [email protected]<mailto:[email protected]> http://lists.ntp.org/listinfo/questions _______________________________________________ questions mailing list [email protected] http://lists.ntp.org/listinfo/questions
