1

i have dropbox account with files. Now, i need to check date, when file changed. If file changed, the script are download new file. If file not changed, i have echo "not downloaded". My file:

if [ -f /root/time.txt ]; then  
dropbox=`cat /root/time.txt | awk '{ print $12 }' | sed "s/,//g;s/\"//g"`  
data=`date -d $dropbox +%Y%m%d%H%M%S`  
echo $data  
dropbox2=`curl -X POST https://api.dropboxapi.com/2/files/get_metadata --header "Authorization: Bearer oc3DfYTzbxAAADDADAqWWh2nyEA21OgecbWedBNB02XRWj8janlbftW123DASy122W" --header "Content-Type: application/json" --data "{\"path\":\"/wwe.txt\",\"include_media_info\":true}" | awk '{ print $12 }' | sed "s/,//g;s/\"//g"`  
data2=`date -d $dropbox2 +%Y%m%d%H%M%S`  
echo $data2 
if [$data -eq $data2]; then  
echo not downloaded 
else    
curl -X POST https://content.dropboxapi.com/2/files/download --header "Authorization: Bearer oc3DfYTzbxAAADDADAqWWh2nyEA21OgecbWedBNB02XRWj8janlbftW123DASy122W" --header "Dropbox-API-Arg: {\"path\": \"/wwe.txt\"}" -o "./wwe.txt"    
fi
else
  curl -X POST https://api.dropboxapi.com/2/files/get_metadata --header "Authorization: Bearer oc3DfYTzbxAAADDADAqWWh2nyEA21OgecbWedBNB02XRWj8janlbftW123DASy122W" --header "Content-Type: application/json" --data "{\"path\":\"/wwe.txt\",\"include_media_info\":true}" -o "./time.txt"   
fi

But,when i start script, i have this output:

1.sh: line 8: 1.sh: [20161008235133: not found

On line 8, i compare two dates (one from file, second from new checking of metada):

if [$data -eq $data2]; then

Where i have error ? Please help.

countermode
  • 7,533
  • 5
  • 31
  • 58
  • You're missing a (needed) space after [ and before ] on that line. This question would be more appropriate on the Unix & Linux or superuser SEs since this isn't a sysadmin question. – Paul Haldane Oct 09 '16 at 14:23
  • The [ is just a synonym for the test command. You could write your statement as well as if test $data -eq $data2 ; .... – ott-- Oct 09 '16 at 21:12

0 Answers0