adding timeout to wget to prevent hanging process - we had such a weird state during - we think - server downtime

This commit is contained in:
sandbender 2011-03-13 21:53:25 +01:00
parent d58e81d3cc
commit c03b50daa0

View File

@ -32,6 +32,7 @@ USER=''
PASSWORD='' PASSWORD=''
TRANSLATE='' TRANSLATE=''
POST='' POST=''
TIMEOUT=200
function usage { function usage {
echo "Usage: pamela-scanner [OPTIONS] echo "Usage: pamela-scanner [OPTIONS]
@ -141,14 +142,14 @@ function translate {
TRANSLATE_URL=${TRANSLATE} TRANSLATE_URL=${TRANSLATE}
TRANSLATE=$(mktemp) TRANSLATE=$(mktemp)
wget --no-check-certificate --quiet -O "${TRANSLATE}" "${TRANSLATE_URL}" wget --timeout="${TIMEOUT}" --no-check-certificate --quiet -O "${TRANSLATE}" "${TRANSLATE_URL}"
POST=$(echo ${POST} | awk -v names="${TRANSLATE}" 'BEGIN { POST=$(echo ${POST} | awk -v names="${TRANSLATE}" 'BEGIN {
RS="\n" RS="\n"
FS="," FS=","
while ((getline nl < names) > 0) { while ((getline nl < names) > 0) {
split(nl, n); split(nl, n);
nms[n[2]] = n[1] nms[n[1]] = n[2]
} }
close(names) close(names)
RS="," RS=","
@ -169,9 +170,9 @@ function translate {
function upload { function upload {
if [ -z "${SIMULATE}" ] if [ -z "${SIMULATE}" ]
then then
RESULT=$(wget "${OUT}" --no-check-certificate -O - --quiet --post-data "data=${POST}" --user "${USER}" --password "${PASSWORD}") RESULT=$(wget "${OUT}" --timeout="${TIMEOUT}" --no-check-certificate -O - --quiet --post-data "data=${POST}" --user "${USER}" --password "${PASSWORD}")
else else
echo Not executing: [wget "${OUT}" --no-check-certificate -O - --quiet --post-data "data=${POST}" --user "${USER}" --password "${PASSWORD}"] echo Not executing: [wget "${OUT}" --timeout="${TIMEOUT}" --no-check-certificate -O - --quiet --post-data "data=${POST}" --user "${USER}" --password "${PASSWORD}"]
RESULT= RESULT=
fi fi