comparison moefetch.sh @ 224:0ac1805621d4

fix for FreeBSD
author edhoprima@gmail.com <edhoprima@gmail.com>
date Sat, 18 Jul 2009 09:10:42 +0000
parents 04ad0b0a3c63
children 265a9ca47a19
comparison
equal deleted inserted replaced
223:04ad0b0a3c63 224:0ac1805621d4
84 # generate link by transforming xml 84 # generate link by transforming xml
85 Generate_Link() { 85 Generate_Link() {
86 echo " 86 echo "
87 Fetching XML file" 87 Fetching XML file"
88 tempnum=1000 88 tempnum=1000
89 _i=1 89 iternum=1
90 > "${TEMP_PREFIX}-list" 90 > "${TEMP_PREFIX}-list"
91 while [ "${tempnum}" -ge 1000 ]; do 91 while [ "${tempnum}" -ge 1000 ]; do
92 wget "http://${SITE}/post/index.xml?tags=${TAGS}&offset=0&limit=1000&page=${_i}" -O "${TEMP_PREFIX}-xml" -e continue=off 92 wget "http://${SITE}/post/index.xml?tags=${TAGS}&offset=0&limit=1000&page=${_i}" -O "${TEMP_PREFIX}-xml" -e continue=off
93 printf "Processing XML file... " 93 printf "Processing XML file... "
94 # xslt evilry 94 # xslt evilry
99 <xsl:value-of select="@file_url" /> 99 <xsl:value-of select="@file_url" />
100 </xsl:template> 100 </xsl:template>
101 </xsl:stylesheet> 101 </xsl:stylesheet>
102 EOF 102 EOF
103 tempnum=$(echo $(wc -l < "${TEMP_PREFIX}-templist")) 103 tempnum=$(echo $(wc -l < "${TEMP_PREFIX}-templist"))
104 _i=$((_i+1)) 104 iternum=$((iternum + 1))
105 cat "${TEMP_PREFIX}-templist" >> "${TEMP_PREFIX}-list" 105 cat "${TEMP_PREFIX}-templist" >> "${TEMP_PREFIX}-list"
106 echo "${tempnum} file(s) available" 106 echo "${tempnum} file(s) available"
107 done 107 done
108 numfiles=$(echo $(wc -l < "${TEMP_PREFIX}-list")) 108 numfiles=$(echo $(wc -l < "${TEMP_PREFIX}-list"))
109 echo "${numfiles} file(s) available on server" 109 echo "${numfiles} file(s) available on server"
131 131
132 Progress_Done() { printf "\bdone\n"; } 132 Progress_Done() { printf "\bdone\n"; }
133 133
134 # getting rid of ls (as per suggestion) 134 # getting rid of ls (as per suggestion)
135 Count_Files() { 135 Count_Files() {
136 _i=0 136 numfiles=0
137 for _f in "${*}/"* "${*}/".*; do 137 for dircontent in "${*}/"* "${*}/".*; do
138 if [ "${_f}" != "${*}/*" ] || [ -e "${_f}" ]; then 138 if [ "${dircontent}" != "${*}/*" ] || [ -e "${dircontent}" ]; then
139 _i=$((_i + 1)) 139 numfiles=$((numfiles + 1))
140 fi 140 fi
141 done 141 done
142 echo $((_i - 2)) 142 echo $((numfiles - 2))
143 } 143 }
144 144
145 # check tools availability 145 # check tools availability
146 Check_Tools() { 146 Check_Tools() {
147 # verify all programs required do indeed exist 147 # verify all programs required do indeed exist