Saya perlu melakukan pemindai multithreading IP tapi saya tidak mengerti, saya perlu "seq" untuk bekerja dengan multitreahding
#! / Bin / bash
function teste(){
for i in $(seq 0 10); do
CONNECT_TIMEOUT=1 # in seconds
A="$1."
B=$i
IP_ADDRESS=$A$B
PORT="${2}"
set +e
data=$(curl --head -vs -m ${CONNECT_TIMEOUT} http://${IP_ADDRESS}:${PORT} 2>&1)
exit_code="$?"
data=$(echo -ne "${data}" | grep "Server: ")
set -e
if [[ ${exit_code} -eq 0 ]]; then
if [[ -n "${data}" ]]; then
echo -ne "${IP_ADDRESS} - ${data}"
else
echo "${IP_ADDRESS} - Got empty data for server!"
fi
else
echo "${IP_ADDRESS} - no server."
fi
done
}
set -e
if [[ $# -ne 2 ]]; then
echo "Usage: $(basename "$0") ip_address_number port"
exit 1
fi
threads=10;
threads=$(( $threads - 1))
for thread in `seq $threads`
do
teste ${1} &
done
linux
bash
shell
multi-threaded
luciano mallmann2
sumber
sumber