Bug#182331: ITP: sleepenh -- an enhanced sleep program for using in shell scripts
>
> You mean this does nothing but
>
> while sleep n; do command; done
>
> ?
>
> --
> Falk
Hi Falk,
It just sleeps some time from current-time or from some initial-time,
with microsecond resolution. If you run it several times, the final
sleep will be the sum of all the sleeps (without cumulative errors
due to several calls to the program) <- this is the feature that I
needed and did not find in any other sleep program.
I'll paste some manpage content. If you have any other question, don't
hesitate do write again.
Sorry for not describing it well in the ITP.
Pedro
-- manpage
NAME
sleepenh - an enhanced sleep program.
SYNOPSIS
sleepenh [initial-time] sleep-time
DESCRIPTION
sleepenh is a program that can be used when there is a
need to execute some functions periodically in a shell
script. It was not designed to be acurate for a single
sleep, but to be acurate in a sequence of consecutive
sleeps.
After a successfull execution, it returns to stdout the
timestamp it finished running, that can be used as ini
tial-time to a successive execution of sleepenh.
OPTIONS
There are no command line options. Run it without any
option to get a brief help and version.
ARGUMENTS
sleep-time is a real number in seconds, with microseconds
resolution (1 minute, 20 seconds and 123456 microseconds
would be 80.123456).
initial-time is a real number in seconds, with microsec
onds resolution. This number is system dependent. In
GNU/Linux systems, it is the number of seconds since mid
night 1970-01-01 GMT. Do not try to get a good value of
initial-time. Use the value suplied by a previous execu
tion of sleepenh.
If you don't specify initial-time, it is assumed the cur
rent-time.
USAGE EXAMPLE
Supose you need to send the char 'A' to the serial port
ttyS0 every 4 seconds. This will do that:
#!/bin/sh
TIMESTAMP=`sleepenh 0`
while true; do
# send the byte to ttyS0
echo -n "A" > /dev/ttyS0;
# just print a nice message on screen
echo -n "I sent 'A' to ttyS0, time now is ";
sleepenh 0;
# wait the required time
TIMESTAMP=`sleepenh $TIMESTAMP 4.0`;
done
Reply to: