Skip to content

Instantly share code, notes, and snippets.

@eik3
Created February 18, 2016 21:20
Show Gist options
  • Save eik3/3b2d11df37cf709977fa to your computer and use it in GitHub Desktop.
Save eik3/3b2d11df37cf709977fa to your computer and use it in GitHub Desktop.
#!/bin/bash
init=true
function do_stuff () {
while :; do
echo -n .
sleep .5
done
}
while :; do
if [ "$(nc -l 9999)" = "on" ]; then
if ! kill -0 $pid 2>/dev/null || $init; then
init=false
do_stuff &
pid=$!
fi
else
kill $pid 2>/dev/null
wait 2>/dev/null
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment