Skip to content
This repository has been archived by the owner on Aug 26, 2019. It is now read-only.

Handbook: Bash

Naja Melan edited this page May 2, 2014 · 4 revisions

Launch a bash command (yeah, it's still going to be necessary for a while) from a box:

box.bash "git commit -m 'changes'"

stdout is returned, but if the bash command returns nonzero, an exception is raised with stderr.

begin box.bash "git commit -m 'changes'" 

rescue Rush::BashFailed => e
  puts "Failed to commit, reason: #{e.message}"
end

Execute from a dir instead of a box in order to set that dir as the current directory before executing:

box['/var/www/myapp/'].bash 'mongrel_rails start'

Pass in a hash of variables to set the environment:

box['/var/www/myapp/'].bash 'mongrel_rails start', :env => { :RAILS_ENV => 'production' }

The :user parameter will use sudo capability, if you're root or a sudoer:

box.bash '/etc/init.d/nginx reload', :user => 'root'

Previous: Processes - Next: Library

source: https://web.archive.org/web/http://rush.heroku.com/handbook/bash

Clone this wiki locally