Skip to content

Commit

Permalink
timestamp: fixed --iso.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole Tange committed Feb 8, 2015
1 parent 1cc67db commit 3a4d914
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
5 changes: 4 additions & 1 deletion Makefile
Expand Up @@ -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 changes: 5 additions & 0 deletions README
Expand Up @@ -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.
Expand All @@ -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 changes: 16 additions & 1 deletion rn/rn
@@ -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
12 changes: 7 additions & 5 deletions timestamp/timestamp
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion timestamp/timestamp.1
Expand Up @@ -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
Expand All @@ -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).
Expand Down
1 change: 1 addition & 0 deletions w4it-for-port-open/w4it-for-port-open
Expand Up @@ -33,6 +33,7 @@ if [ -z "$NC" ] ; then
fi

while ! is_port_open ; do
sleep 1
print_not_reachable
done
echo

0 comments on commit 3a4d914

Please sign in to comment.