From: Tobias Reif Date: 2002-05-24T20:38:59+09:00 Subject: OS independent scripts, system calls on Windows and Linux Hi, I need to script some tools (Xerces, Saxon, Dot, etc). Since it should be OS independent, and must run unchanged on at least Linux and any Windows, and should be very simple, elegant, and quick to write, I choose Ruby over .bat or .sh scripts. I'll chain about seven actions, and need to know if there were errors at any point, or if all went well. I'm not that experienced yet, so I might miss some obvious solutions, but AFAICS, the backtick system call mechanism returns stdout/sterr, but is not OS independent. If that's so, it should be made OS independent IMHO; That would be the simplest solution for me. I don't want to write all the cmd.exe stuff for various Windowses, each time I write a little script. The system() method seems to be OS independent, but doesn't return anything, IIRC. (again: I didn't yet test or read enough; please correct my assumptions) Perhaps something like: commands = # ... commands.each do |cmd| returned = system cmd # system (or 'rsys') would return # sterr, or stdout, or nil if returned case ret when Stderr then raise returned when Stdout then puts returned end end end Or is there already a way to write an equiv of the above which is as short, or shorter? Ideally there would be commands.run which would do what the above pseudo code outlines. Tobi -- http://www.pinkjuice.com/