Created
December 1, 2023 17:57
-
-
Save lyatziv/4960fe0b3abb1c26fbdf36c2e0f093aa to your computer and use it in GitHub Desktop.
Verify Pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://github.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# chmod +x test_sites.sh | |
# Usage: ./test_sites.sh targets.txt | |
# Check if a file path is provided as an argument | |
if [ $# -eq 0 ]; then | |
echo "Usage: $0 <file_path>" | |
exit 1 | |
fi | |
file_path=$1 | |
# Check if the file exists | |
if [ ! -f "$file_path" ]; then | |
echo "File not found: $file_path" | |
exit 1 | |
fi | |
# Define the number of threads (adjust as needed) | |
num_threads=256 | |
cookie="" | |
# Function to test a URL | |
test_url() { | |
url=$1 | |
echo "Testing $url..." | |
for ((i=1; i<=128; i++)); do | |
response_code=$(curl --cookie "cookie=$cookie" -s -o /dev/null -w "%{http_code}" "$url") | |
if [ "$response_code" -eq 200 ]; then | |
echo " Attempt $i: $url is reachable." | |
else | |
echo " Attempt $i: $url is not reachable." | |
i-- # Retry | |
fi | |
done | |
echo "Done ALL testing $url." | |
} | |
# Export the function to make it available to xargs | |
export -f test_url | |
# Read each URL from the file and run tests in parallel | |
cat "$file_path" | xargs -n 1 -P "$num_threads" -I {} bash -c 'test_url "$@"' _ {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment