Skip to content

Instantly share code, notes, and snippets.

@sowawa
Created February 2, 2012 20:46
Show Gist options
  • Save sowawa/1725660 to your computer and use it in GitHub Desktop.
Save sowawa/1725660 to your computer and use it in GitHub Desktop.
get cmd output by ruby.
module CMDUtils
def get_cmd_output cmd
output = ''
IO.popen(
cmd
) do |io|
output = io.read()
end
output
end
module_function :get_cmd_output
end
@sowawa
Copy link
Author

sowawa commented Feb 2, 2012

The usage is

require './cmd_utils.rb'
p CMDUtils.get_cmd_output 'ls'

@kumagi
Copy link

kumagi commented Feb 2, 2012

thanks!

@keikubo
Copy link

keikubo commented Mar 28, 2012

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment