From: nobu.nokada@... Date: 2002-05-29T18:58:35+09:00 Subject: Re: OS independent scripts, system calls on Windows and Linux Hi, At Wed, 29 May 2002 18:04:00 +0900, Tobias Reif wrote: > I want to get what the command returns; if possible, I'd like to know > if there was any of stdout, stderr, or both, or nothing, so I can > choose what to do with the returned strings/objetcs, or if to raise an > error. Would that be feasible? > > Syntax *could* look like (this probably has errors) I'm thinking like this: currthr = Thread.current ['this -x -y','that -a -b'].each do |cmd| process = Process.start(cmd, :stdout=>true, :stderr=>true) # pipes stdout and stderr, # would raise when couldn't run `cmd'. Thread.new(process.stderr) do |f| # if something from stderr, it's error. currthr.raise error if error = f.read end puts process.stdout process.wait.exitcode == 0 or raise end BTW, why do you need to use stderr to detect errors? Your commands don't return exit code? At Fri, 24 May 2002 22:19:59 +0900, Tobias Reif wrote: > I need a very simple way to issue the list of commands, in a very > simple and highly platform independent way. If you just need to run successive commands only when preceding commands succeeded, this doesn't help? <