Skip to content

Instantly share code, notes, and snippets.

@operator-DD3
Created July 20, 2014 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save operator-DD3/e10608a6abd6a53713b2 to your computer and use it in GitHub Desktop.
Save operator-DD3/e10608a6abd6a53713b2 to your computer and use it in GitHub Desktop.
Execute command
function os.capture(cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment