Untitled
unknown
sh
a year ago
895 B
2
Indexable
Never
# Define the URLs urls=("http://example.com/url1" "http://example.com/url2") # Function to check the HTTP status code check_status_code() { local url="$1" local http_code=$(curl -o /dev/null -s -I -w "%{http_code}" "$url") echo "$http_code" } # Initialize an array to store HTTP status codes http_codes=() # Run curl requests in parallel using & for url in "${urls[@]}"; do (http_code=$(check_status_code "$url") http_codes+=("$http_code") ) & done # Wait for all background jobs to finish wait # Check the http_codes array after the background jobs are completed success=true for http_code in "${http_codes[@]}"; do if [ "$http_code" != "200" ]; then success=false break fi done if $success; then echo "All requests returned 200 OK." else echo "At least one request did not return 200 OK." fi