You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Princeton/pu/libexec/check_ssh_response

35 lines
518 B
Bash

#!/bin/bash
#
# Script to check if SSH returns a certain string for password query
#
expect=/usr/bin/expect
if [[ ! -x "$expect" ]]; then
echo "\"$expect\" was not found, or is not executable"
exit 3
fi
if [[ "$#" -ne "2" ]]; then
echo "Usage: check_ssh_response <hostname> <response_regex>"
exit 3
fi
$expect -f - <<%
log_user 0
spawn ssh -o ConnectTimeout=60 $1
expect {
eof {
puts "Error connecting to $1"
exit 2
}
-re "$2"
}
puts "SSH ready for service on $1"
exit 0
"
%