[dev] New utility "when"

From: Andrew Gwozdziewycz <web_AT_apgwoz.com>
Date: Wed, 11 Dec 2013 11:31:40 -0500

Hey all,

If you've used watch(1) you know that running a command repeatedly is
useful. What I wished for yesterday though, is for a mechanism that
notified me when a command succeeded, but is long running -- say an
ssh session.

I wondered if I could do it in shell, but figured it might be too
tricky to do concisely, so I wrote a C program that combines SIGALRM
and SIGCHLD into something that works fairly well (though, I've only
tested it on OS X so far, yeah, I know), but probably murders POSIX
standards (I haven't written Unix C in a while, so my Stevens books
are rusty)

Anyway, source is on github: https://github.com/apgwoz/when

Example usage:

    when "make" "xmessage 'that long running build actually worked'"

(This is no different than a simple while ! `make` ... of course)

But, using -t is where the "magic" happens. Lets say you're waiting
for a host to come up on AWS or something:

    when -t "ssh user_AT_host" "xmessage 'Connected'"

When the ssh command finally succeeds, xmessage will pop up saying
'Connected' and the prompt will still be there.

Maybe one of you will stop laughing long enough to find it useful.



Received on Wed Dec 11 2013 - 17:31:40 CET

This archive was generated by hypermail 2.3.0 : Wed Dec 11 2013 - 17:36:07 CET