diff options
Diffstat (limited to 'bin/redirect.sh')
-rwxr-xr-x | bin/redirect.sh | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/bin/redirect.sh b/bin/redirect.sh index d309f1a..405a84d 100755 --- a/bin/redirect.sh +++ b/bin/redirect.sh @@ -1,18 +1,27 @@ #!/bin/bash -OUTFILE="/tmp/tmp_redirect_out" +OUTFILE="/tmp/tmp_redirect_out.txt" cmd="curl -v $1" `$cmd &> $OUTFILE` -RES=`grep "< HTTP.*303" $OUTFILE` +ERR=`grep -a "< HTTP.*5[0-9][0-9]" $OUTFILE` +ERR=${ERR// /} # remove emtpy spaces + +if [ -z $ERR ]; then + ERR="no error" +else + echo "ERROR" 1>&2 + exit 1 +fi + +RES=`grep -a "< HTTP.*30[0-9]" $OUTFILE` RES=${RES// /} # remove emtpy spaces #echo $RES if [ -z $RES ]; then - #echo "no" - echo "" + exit 0 else #cat $OUTFILE RES=`grep "< Location: " $OUTFILE` |