这个SH文件发生了什么?

时间:2014-03-20 10:22:42

标签: bash shell curl

我认为这是一个bash编码。它是关于通过curl测试加载服务器。但我根本得不到它。任何人都可以解释这个文件中发生了什么?

curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!" 
curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!" 
curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!" 
curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!" 
curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!" 
curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!" 
curl -s "http://admin.yumyummi.com/api/dbsync/getUpdateLogs?app_last_update_time=&curl=a{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!"  

for job in $pidlist do 
  echo $job     
  wait $job || let "FAIL+=1" 
done  

if [ "$FAIL" == "0" ]; then 
  echo "YAY!" 
else 
  echo "FAIL! ($FAIL)" 
fi

1 个答案:

答案 0 :(得分:1)

请参阅脚本内的评论:

# Curl the url http://myurl.com/ - but don't output anything (-s)
# Try different parameters of the url: http://myurl.com/?1-1 (not quite sure about the brackets)
# Send the process to the background (&)
curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &

# Add the process id (pid) of the most recent process ($!) to a variable named pidlist
# In that case it's the pid of the previous curl command
pidlist="$pidlist $!"

curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!" 
curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!" 
curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!" 
curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!" 
curl -s "http://myurl.com/?{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!" 
curl -s "http://admin.yumyummi.com/api/dbsync/getUpdateLogs?app_last_update_time=&curl=a{1,2,3,4,5}-[1-1000]" &
pidlist="$pidlist $!"  

# For each pid in the pidlist variable do something
for job in $pidlist do

  # Echo/output the process id
  echo $job

  # Wait for the process to finish. If the process returns an error add 1 to the variable FAIL
  wait $job || let "FAIL+=1" 
done  

# If the variable $FAIL is 0
if [ "$FAIL" == "0" ]; then

  # Echo/output the string "YAY!"
  echo "YAY!"

# If the variable $FAIL is not 0
else 

  # Echo/output the string "FAIL!" + the integer value of the variable $FAIL representing the
  # number or errors
  echo "FAIL! ($FAIL)" 
fi
相关问题