Created
October 13, 2011 10:12
-
-
Save gouthamvel/1283904 to your computer and use it in GitHub Desktop.
open3 sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open3' | |
def cmd_exe(cmd, &block) | |
output = nil | |
Open3.popen3(cmd) do |stdin, stdout, stderr| | |
output = stdout.readlines | |
error = stderr.readlines | |
p error | |
unless error.empty? | |
p "#{cmd} Failed " | |
yield false if block_given? | |
raise "#{cmd} #{error} Failed" | |
end | |
end | |
yield true if block_given? | |
output | |
end | |
dir_name = '/tmp/fromdoss' | |
list_of_files = cmd_exe "ls /tmp/*" do |status| | |
return false unless status | |
end | |
# list_of_files.each { |e| cmd_exe "fromdos #{e}" } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment