可以使用linux bash工具同时向多个主机发送http-get请求吗?
此刻我做

wget -O- http://192.168.1.20/get_data-php > out.log
但是我需要请求所有192.168.1.0/17 IP。

最佳答案

#!/bin/sh
rm address.txt allout.txt # remove old file with addresses and contents
nmap -n -sn 192.168.1.0/17 -oG - | awk '/Up$/{print $2}' > address.txt # get all active hosts and store into a file address.txt

while IFS="" read -r add || [ -n "$add" ]
do
  wget -q -O- http://"$add"/get_data-php > out"$add".log & # for every address create file with wget content
done < address.txt

wait

cat out*.log > allout.txt # put all .log file contents to allout.txt

rm -r out*.log # remove all created .log files

07-24 09:52
查看更多