#!/bin/bash #author: Bryan Bishop #date: 2011-07-08 #i threw this together in like 5min so give me a break counter=$1 url="http://sandbox.quartzy.com/reagent/downloadReagentVendor/with_comments/1/anon/0/rea_id/$counter" #cookie="symfony=ou9sf20iobvo4qd3ve4sj9mcp0" #cookie="symfony=8bg1g85gnc7ube10jfk9uve7v1" cookie="symfony=vfmmhdnlen3u4iquipb3sj7cu5" headers=`curl -Q "OPTS UTF8 ON" -s --cookie $cookie -I $url` headerfilename=`echo -e "$headers" | grep filename`; filename=`echo -e "$headerfilename" | cut -d"=" -f2`; filenametest=`echo -e "$filename" | grep pdf`; filenametestpart2=$? size=`echo -e "$headers" | grep Content-Length | cut -d" " -f2 | tr -d "\r"`; if [ "$filenametestpart2" -eq "0" ]; then if [ "$size" -gt 1592 ]; then #it's a pdf file.. go ahead and download it echo -e "$size bytes\t\tfilename: $filename" partialfilename=`echo $filename | awk -F\" '{print $(NF-1)}' | sed 's/\//-SLASH-/g'` curl -s --cookie $cookie $url > "files2/$counter--$partialfilename" else echo "..too small: $counter;$size" fi else #nope.. not a pdf echo "..skipping $counter.."; fi