if you use `cmd_exec` from the Post::Common mixin, you can simplify a lot of this code.  Something like:
```ruby
output = cmd_exe(cmd)
output.each_line do |line|
  ...
end
```