timestamp: fixed --iso.

This commit is contained in:
Ole Tange 2015-02-08 20:54:41 +01:00
parent 1cc67db6a1
commit 3a4d91432b
6 changed files with 36 additions and 8 deletions

View file

@ -15,8 +15,11 @@ tracefile/tracefile.1: tracefile/tracefile.pod
timestamp/timestamp.1: timestamp/timestamp
pod2man timestamp/timestamp > timestamp/timestamp.1
wssh/wssh.1: wssh/wssh
#pod2man wssh/wssh > wssh/wssh.1
install:
mkdir -p /usr/local/bin
parallel ln -sf `pwd`/{}/{} /usr/local/bin/{} ::: blink reniced em field forever neno rn stdout tracefile w4it-for-port-open upsidedown histogram goodpasswd mtrr not summer timestamp transpose
parallel ln -sf `pwd`/{}/{} /usr/local/bin/{} ::: blink reniced em field forever neno rn stdout tracefile w4it-for-port-open upsidedown histogram goodpasswd mtrr not summer timestamp transpose wssh
mkdir -p /usr/local/share/man/man1
parallel ln -sf `pwd`/{} /usr/local/share/man/man1/{/} ::: */*.1

5
README
View file

@ -4,6 +4,8 @@ Probably not useful for you, but then again you never now.
em - Force emacs to run in terminal. Use xemacs if installed.
field - Split on space. Give the given field number. Support syntax 1-3,6-
forever - Run the same command or list of commands every second.
neno - No error no output. Only print STDERR and STDOUT if the command fails.
@ -16,3 +18,6 @@ stdout - Redirect both STDERR and STDOUT to STDOUT.
tracefile - List files being accessed by program.
w4it-for-port-open - Block until the given port opens on a given host.
wssh - Shorthand for w4it-for-port-open $host 22; ssh $host

17
rn/rn
View file

@ -1,4 +1,19 @@
#!/bin/bash
mkdir ~/.rm 2>/dev/null
mv "$@" ~/.rm
if mv "$@" ~/.rm ; then
# OK
true
else
mkdir -p ~/.rm/{1..10}
mv "$@" ~/.rm/1 2>/dev/null ||
mv "$@" ~/.rm/2 2>/dev/null ||
mv "$@" ~/.rm/3 2>/dev/null ||
mv "$@" ~/.rm/4 2>/dev/null ||
mv "$@" ~/.rm/5 2>/dev/null ||
mv "$@" ~/.rm/6 2>/dev/null ||
mv "$@" ~/.rm/7 2>/dev/null ||
mv "$@" ~/.rm/8 2>/dev/null ||
mv "$@" ~/.rm/9 2>/dev/null ||
mv "$@" ~/.rm/10
fi

View file

@ -216,14 +216,17 @@ while(<>) {
if($opt::rfc) {
# RFC822 (actually RFC2822, as the year has 4 digits)
print strftime("%a, %d %b %Y %H:%M:%S.".$ms." %z", localtime($to_print)), " ", $_
print strftime("%a, %d %b %Y %H:%M:%S.".$ms." %z", localtime($now)), " ", $_
} elsif($opt::iso) {
# ISO8601
print strftime("%Y-%m-%dT%H:%M:%S".$ms, localtime($to_print)), $tz , " ", $_;
print strftime("%Y-%m-%dT%H:%M:%S.".$ms, localtime($now)), $tz , " ", $_;
} elsif($opt::isotime) {
# ISO8601 time part only
print strftime("%H:%M:%S.".$ms, localtime($to_print)), $tz, " ", $_;
print strftime("%H:%M:%S.".$ms, localtime($now)), $tz, " ", $_;
} elsif($opt::epoch) {
# Seconds since epoch
print strftime("%s.".$ms, localtime($now)), " ", $_;
} elsif(@opt::delta) {
# Seconds since epoch
print strftime("%s.".$ms, localtime($to_print)), " ", $_;
} else {
@ -232,8 +235,7 @@ while(<>) {
}
sub set_defaults {
if(not($opt::rfc || $opt::iso || $opt::isotime || $opt::epoch)) {
$opt::epoch = 1;
if(not($opt::epoch || $opt::rfc || $opt::iso || $opt::isotime || $opt::epoch)) {
if(not @opt::delta) {
@opt::delta = (1);
}

View file

@ -124,7 +124,7 @@
.\" ========================================================================
.\"
.IX Title "TIMESTAMP 1"
.TH TIMESTAMP 1 "2013-05-22" "perl v5.14.2" "User Contributed Perl Documentation"
.TH TIMESTAMP 1 "2014-02-14" "perl v5.14.2" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@ -141,6 +141,8 @@ timestamp \- prepend timestamp to output
.IX Item "--delta (default)"
Regard start time as epoch and thus show difference between start time
and now.
.Sp
If \fB\-\-delta\fR is repeated: The time spent between each line.
.IP "\fB\-\-rfc\fR" 9
.IX Item "--rfc"
Output time format in \s-1RFC822\s0 (E.g. Wed, 30 Jan 2013 13:57:58 \s-1GMT\s0).

View file

@ -33,6 +33,7 @@ if [ -z "$NC" ] ; then
fi
while ! is_port_open ; do
sleep 1
print_not_reachable
done
echo