# return the evaluated parameter if available or $2 $3 ... $n
if grep -qe "^$1=" $CONF; then
- grep -e "^$1=" $CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | sed -e 's/#.*$//'
+ grep -e "^$1=" $CONF | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | sed -e 's/ *#.*$//'
else
shift
echo $*
fi
if [ "$protocol" == "http" ]; then
- (cd $3 && wget $wget_timeout $1/$2)
+ wget $wget_timeout $1/$2 -O $3/$2
elif [ "$protocol" == "ftp" ]; then
if [ "$PASSIVE_FTP" == "1" ]; then
wget_passive_ftp="--passive-ftp"
ncftpget_passive_ftp="-F"
fi
if [ "$FTP_TOOL" == "ncftpget" ]; then
- (cd $3 && ncftpget $ncftpget_timeout $ncftpget_passive_ftp $1/$2)
+ ncftpget -c $ncftpget_timeout $ncftpget_passive_ftp $1/$2 > $3/$2
elif [ "$FTP_TOOL" == "wget" ]; then
- (cd $3 && wget $wget_timeout $wget_passive_ftp $1/$2)
+ wget $wget_timeout $wget_passive_ftp $1/$2 -O $3/$2
else
echo $BASENAME: error: invalid value for config variable FTP_TOOL: $FTP_TOOL
echo $BASENAME: please check your config file $CONF
fi
elif [ "$protocol" == "file" ]; then
url="`echo $1 | sed -e 's/file:\/\///'`"
- cp $url/$2 $3 2> /dev/null
+ if [ -f "$url/$2" ]; then
+ echo -n "Copying $url/$2..."
+ cp $url/$2 $3/$2 2> /dev/null
+ if [ "$?" == "0" ]; then
+ echo " done."
+ else
+ echo " failed."
+ fi
+ fi
fi
}