-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplit.sh
executable file
·46 lines (38 loc) · 1.03 KB
/
split.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Base URL
base_url="http:/localhost:1633/chunks"
# Check if the file path is provided as a command-line argument
if [ -z "$1" ]; then
echo "Usage: $0 <file_path>"
exit 1
fi
# Assign the command-line argument to file_path
file_path="$1"
# Read each line from the file
while IFS= read -r line
do
# Construct the full URL
url="${base_url}/${line}"
# echo $url
# Limit the number of parallel jobs to 50
while [ "$(jobs | wc -l)" -ge 100 ]; do
wait -n
done
# Run the curl command in the background
{
# Check the HTTP status code
status_code=$(curl -o /dev/null -s -w "%{http_code}\n" "$url")
if [ "$status_code" -eq 200 ]; then
echo "ok"
else
echo "fail"
fi
# response=$(curl "$url" -s)
# is_retrievable=$(echo "$response" | jq -r '.isRetrievable')
# if [ "$is_retrievable" == "true" ]; then
# echo "ok"
# else
# echo "fail"
# fi
} &
done < "$file_path"