2

I want to use Fabric to chown all the files in a directory - including hidden files. Since Fabric uses the sh shell and not bash and sh doesn't know shopt, I can't do:

local('shopt -s dotglob')
local('sudo chown -R name dir')

I don't think there is a way to use the bash shell in Fabric. Is there another way to do this?

Mitch
  • 2,350
  • 7
  • 29
  • 48

1 Answers1

1

How about using another strategy to recursively chown everything in the directory, including hidden files and directories:

local('sudo find dir -exec chown name {} \;')

Hope that helps.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • That looks good, thanks. Could you explain what the "{} \;" does? – Mitch Jul 10 '13 at 20:59
  • You are welcome. It works like `xargs` - needed for passing the next result of find to the `chown`. In other words `{}` will be replaced with the next file/dir name. `\;` is greatly explained [here](http://stackoverflow.com/a/6085237/771848). – alecxe Jul 10 '13 at 21:04
  • 1
    Another alternative from [http://stackoverflow.com/questions/8005348/why-doesnt-fabric-see-my-bash-profile]: `local("/bin/bash -l -c 'shopt -s dotglob'")` – Mitch Jul 11 '13 at 03:03
  • Also in more recent versions of Fabric (1.6 at least and I am using 1.3), the local function accepts shell as a keyword parameter. – Mitch Jul 11 '13 at 19:31