make getpeername() return the original socket address which before it was intercepted
[hband-tools.git] / user-tools / fgat
blob12b0daa376e069f4d438beb1506dff2e7c0a91af
1 #!/bin/bash
3 set -e
5 now=`date +%s`
6 terminus=`date +%s -d "$1"`
7 shift
8 declare -a command
9 command=("$@")
12 if [ -z "$1" ]
13 then
14 echo "No command specified." >&2
15 exit 252
17 if [ $terminus -lt $now ]
18 then
19 echo "Time past." >&2
20 exit 253
23 at=`date -d @$terminus`
24 echo "Command scheduled to run at $at." >&2
27 while [ $terminus -gt $now ]
29 set +e
30 sleep $[$terminus - $now]
31 set -e
32 now=`date +%s`
33 done
35 exec "${command[@]}"
36 exit $?
40 true <<EOF
42 =pod
44 =head1 NAME
46 fgat - Execute command in foreground at a given time
48 =head1 SYNOPSIS
50 fgat <B<time-spec>> <B<command>> [B<arguments>]
52 =head1 DESCRIPTION
54 In opposite of at(1), fgat(1) stays in console's foreground and waits for B<time-spec>, after that runs B<command>.
55 B<time-spec> can be any string accepted by date(1).
57 =cut
59 EOF