0

I'm trying to create a shell-script to manage my sync with a s3-bucket. Here is what is in my script:

#!/bin/bash

aws s3 sync $1 $2 $(for word in $(echo "$excludeconf"| tr ";" " "); do echo -n "--exclude \"$word\" "; done) $del --no-follow-symlinks $3

$1 is source $2 is destination $3 is another parameter that gets passed (dryrun). the $(word... takes a list of files & folders $excludeconf and creates --exclude ... with them.

If I run the script it won't exclude anything.

If I put an echo in front of the command above, I get this:

aws s3 sync . s3://BUCKETNAME/FOLDERNAME/ --exclude .SOMEFILE --exclude "public/icon/*" --delete --no-follow-symlinks --dryrun

If I copy that command and run it manualy inside the terminal it works just fine.

Any ideas?

FYI: I'm running CentOS 7

Edit:

after some tests I found out the problem is globbing: the public/icon/* gets interpreted to public/icon/folder1 public/icon/folder2 If I try to set noglob it won't work.. is ist because it is inside $(..)?

Damon
  • 1
  • 3
  • how are you running the script when it does not work? The dot may be interpreted differently in that case. – LMC May 29 '18 at 21:20
  • I added it (#!/bin/bash) – Damon May 29 '18 at 21:24
  • ok, but how is it executed. cron? – LMC May 29 '18 at 21:25
  • Add a `--debug` parameter and see what it says. (And you probably want to remove `--dryrun`) – John Rotenstein May 29 '18 at 22:38
  • This is basically https://stackoverflow.com/questions/12136948/why-does-shell-ignore-quotes-in-arguments-passed-to-it-through-variables , and the solution is the same: use an array. – that other guy May 29 '18 at 23:25
  • I execute it manuela ./script.sh; I'll try debug later. dryrun/or not makes no difference. – Damon May 30 '18 at 10:27
  • after some tests I found out the problem is globbing: the `public/icon/*` gets interpreted to `public/icon/folder1 public/icon/folder2` If I try to set noglob it won't work.. is ist because it is inside `$(..)`? – Damon May 30 '18 at 13:36

1 Answers1

0

I've rewritten the script in python and changed it to:

os.system("set -f noglob && aws s3.....")

That worked.

Damon
  • 1
  • 3