Skip to content
This repository was archived by the owner on Mar 30, 2020. It is now read-only.

Commit da1c09b

Browse files
committed
find the longest hostname for prettier output
1 parent 9fa5fbb commit da1c09b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

ssh-test

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,17 @@ fi
5151
# MAIN
5252
#
5353

54+
longest_hostname=0
55+
for h in $(cat $1); do
56+
length=${#h}
57+
[ $length -gt $longest_hostname ] && longest_hostname=$length
58+
done
59+
5460
RED='\033[1;31m'
5561
NC='\033[0m' # No Color
5662

5763
for h in $(cat $1); do
58-
printf "%30s ... " $h
64+
printf "%${longest_hostname}s ... " $h
5965
if ssh -q -o BatchMode=yes -o ConnectTimeout=3 $h exit 2>/dev/null; then
6066
echo "OK"
6167
else

0 commit comments

Comments
 (0)