Reputation: 83
i want to connect to a secure ftp server and check inside each file inside a directory if its modification date is more than 3 days.
want to achieve this with a bash script using CURL.
here is what i have tried :
for i in `curl -l -k --ftp-ssl ftp://"$ftp_username":"$ftp_password"@$ftp_ip:$ftp_port/$ftp_path/ `; do
{
echo "Checking the modification date of $i";
if ["$(( $(date +"%s") - $(stat -c "%Y" $i) ))" -gt "259200" ]; then
echo "modified file found ";
else
echo "no modified file found";
fi
};
done;
i get this error :
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 3266 0 0 6980 0 --:--:-- --:--:-- --:--:-- 7525
Checking the modification date of products
stat: cannot stat `products': No such file or directory
./remove_products.sh: line 18: 1373903124 - : syntax error: operand expected (error token is "- ")
what am i doing wrong ?
any help would be appreciated
Upvotes: 2
Views: 862
Reputation: 780843
Change:
if ["$(( $(date +"%s") - $(stat -c "%Y" $i) ))" -gt "259200" ]; then
to:
if [ "$(( $(date +"%s") - $(stat -c "%Y" $i) ))" -gt "259200" ]; then
Spaces around the [
are required.
Upvotes: 1