From: "Iñaki Baz Castillo" Date: 2009-10-28T00:12:31+09:00 Subject: Re: how can I do a linux mount in a programmatic way ? El Martes, 27 de Octubre de 2009, Jedrin escribió: > If I do something like system('sudo mount .. ') then I don't really > get any error codes back to see what happened because I just get the > sudo return code here. Is there a way to do this like a library call > in ruby ? > Use open4 (gem install open4): ------------------- require "open4" pid, stdin, stdout, stderr = Open4::popen4("sudo mount...") ignored, status = Process::waitpid2 pid if status.to_i != 0 puts "Error: Command returned #{status.to_i}"" end --------------------- You can also inspect the output and error output reading stdout and stderr (they are IO objects, no strings). -- Iñaki Baz Castillo