Skip to content

Instantly share code, notes, and snippets.

@razorcd
Created June 8, 2016 17:03
Show Gist options
  • Save razorcd/367302c8752d9ddc6aee0380459dd77c to your computer and use it in GitHub Desktop.
Save razorcd/367302c8752d9ddc6aee0380459dd77c to your computer and use it in GitHub Desktop.
ways to run shell commands in Ruby
exec("echo 'hello world'") # exits from ruby, then runs the command
system('echo', 'hello world') # returns the status code
sh('echo', 'hello world') # returns the status code
`echo "hello world"` # returns stdout
%x[echo 'hello world'] # returns stdout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment