From 691c411e9a5eb7470a602aa1f9122d6f9a1b89df Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Sun, 30 Apr 2023 15:21:00 -0400 Subject: commit old changes from work tree --- ssh-check | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/ssh-check b/ssh-check index c2f18d7..086ddd9 100755 --- a/ssh-check +++ b/ssh-check @@ -18,13 +18,23 @@ quietly() "$@" /dev/null 2>&1 } -c () +match() +{ + local search_text="$1" search_pattern + shift + for search_pattern in "$@" + do + case "$search_text" in + $search_pattern) return ;; + esac + done + false +} + +main() { local h hosts $read_all -r hosts < "$CFG_FILE" - if [ $# = 0 ]; then - set -- -4 - fi host_field_width=1 for h in $hosts do @@ -37,6 +47,8 @@ c () { for h in $hosts do + [ $# = 0 ] || match "$h" "$@" || continue + ( if uptime=$(ssh $SSH_OPTIONS -n "$h" -- uptime 2>/dev/null) then printf "%-15s %-${host_field_width}s %s\n" "Succeeded:" "$h" "${uptime# }" @@ -74,7 +86,8 @@ do --edit) do_edit=y;; --run) run_anyway=y;; --) shift; break;; - *) exit 1 ;; + -*) exit 1 ;; + *) break;; esac shift done @@ -92,4 +105,4 @@ then edit_config fi -c "$@" +main "$@" -- cgit v1.2.3