How can you check to see if a file exists (on the remote server) in Capistrano?

In capistrano 3, you can do:

on roles(:all) do
  if test("[ -f /path/to/my/file ]")
    # the file exists
  else
    # the file does not exist
  end
end

This is nice because it returns the result of the remote test back to your local ruby program and you can work in simpler shell commands.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)