Files
sf_databuffer/file_stats.sh
2018-08-10 16:21:28 +02:00

21 lines
617 B
Bash
Executable File

#!/bin/bash
HOST="https://dispatcher-api.psi.ch/sf"
# HOST="http://localhost:8080"
HTTP_ADDRESS="/channels/statistics/byFile"
RESPONSE=response.json
# see http://stackoverflow.com/questions/18258804/how-to-catch-timeout-errors-in-a-curl-shell-script
COMMAND="curl -s -w %{http_code} -X POST"
while read -r -d '' filename; do
COMMAND+=" -F files=@${filename}"
done < <(find . \( -name "*.sources" -o -name "*.request" \) -print0)
COMMAND+=" ${HOST}${HTTP_ADDRESS} -o ${RESPONSE}"
# echo "Execute command: "${COMMAND}
STATUS=$(${COMMAND})
cat ${RESPONSE} | python -m json.tool
rm -f ${RESPONSE}
#echo ${STATUS}