From eb59877b0b9db7bdf0d0326d09d096ff77b9e282 Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sat, 10 Feb 2024 23:43:13 -0500 Subject: improvements? --- ssh-check | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/ssh-check b/ssh-check index 5045bb1..6d23b59 100755 --- a/ssh-check +++ b/ssh-check @@ -3,10 +3,7 @@ CFG_FILE=$HOME/.config/ssh-check.list TIMEOUT=5 # seconds - -read_all='read -N2147483647' - -$read_all SSH_OPTIONS </dev/null) - then - printf "%-15s %-${host_field_width}s %s\n" "Succeeded:" "$h" "${uptime# }" - else - printf "%-15s %-${host_field_width}s\n" "Failed:" "$h" - fi ) & + ( + #.........."1234567890123456" + successpat=" Success: %-${host_field_width}s %s\n" + failurepat="*FAILURE: %-${host_field_width}s\n" + if command_stdout=$(ssh -n $SSH_OPTIONS \ + "$h" -- \ + ${REMOTE_COMMAND:-uptime} \ + 2>/dev/null) + then + printf "$successpat" "$h" "${command_stdout# }" + else + printf "$failurepat" "$h" + fi + ) & done wait } | column -t -s'$' -- cgit v1.2.3