Re: [dev] New utility "when"

From: Patrick <201009-suckless_AT_haller.ws>
Date: Thu, 12 Dec 2013 02:14:46 +0800

On 2013-12-11 12:21, Andrew Gwozdziewycz wrote:
> Yes. You can do exactly that. But you *can't* do:
> when -t "ssh user_AT_host" "xmessage 'Connected'"

Time to rock the IPC?

#!/bin/bash
MAGIC=5

system_time_epoch() { date +%s; }
file_time_mod() { stat --printf='%Y' $1 ; }
file_age() { echo $(( $(system_time_epoch) - $(file_time_mod "$1") )); }

tmp="/tmp/michael_jackson_touched_my_$$"
touch $tmp

(
while test $( file_age $tmp) -lt $MAGIC; do sleep 1; done
xmessage "wtf? you let him touch your $$"
) &

while ! ssh $there ; do
        touch $tmp
done
Received on Wed Dec 11 2013 - 19:14:46 CET

This archive was generated by hypermail 2.3.0 : Wed Dec 11 2013 - 19:24:07 CET