From: ptkwt@...2.teleport.com (Phil Tomson) Date: 2001-01-07T00:40:02+09:00 Subject: [ruby-talk:8741] Druby and `backquotes (bug or just me?) I've got the following code running on a PC (running windows): #drb_srvr.rb #this is the server, let's say the machine name is elmer require 'drb' require 'socket' include Process class TestServer def initialize(hostname) @hostname = hostname @threads = 0 p "starting TestServer on #{@hostname}" end #status commands: #check the OS version of the PC: def osver puts "got osver command" `uname -r` #of course this is bogus on Windows! end #get the current working directory of the PC: def pwd Dir.pwd end end host = Socket.gethostname aServerObj = TestServer.new(host) DRb.start_service('druby://localhost:9000', aServerObj) DRb.thread.join (Actually, there's more, but this is the important part) And I have the following (or close to it, I've cut out a lot) client running on a linux box: #this is the client require 'drb' DRb.start_service() drbObj = DRbObject.new(nil, "druby://elmer:9000") #later: drbObj.osver drbObj.pwd ################################################## Now what happens is that on the Windows PC side I get: starting TestServer on elmer got osver command drb_srver.rb:10: command not found uname -r And then it just stops (on the client side as well). The drbObj.pwd command never gets executed on the client side (the linux box). Now, of course, there is no such command as uname on Windows, hence the error. The problem is that because of this error, the client just hangs. I think that perhaps this has something to do with the fact that the output of the `uname -r` on the Windows machine just gets sent to STDERR and so there is nothing to be sent back as a result from the osver method. If this is the case, how might I get around this? I tried something like: `uname -r 2>&1` but no help (of course this kind of redirection may not do anything on Windows 98). As an experiment, I also tried redefining the backquote method as shown on pg 75 of the Programming Ruby book: #change to drb_srvr (the Windows side) alias oldBackquote ` #`#just to make all the colorization workout #the following is to make sure that if an illegal command was #executed it doesn't stop the whole server! def `(cmd) puts "In new backquote!" result = oldBackquote(cmd) if $? != 0 puts "$? is: #{$?}" return "fail" end puts "result is: #{result}" return result end It doesn't work either - I get to where it puts "In new backquote!", but it never goes on from there. From this it would seem that my theory about the output of an erroneous `(cmd) only going to STDERR isn't what the problem is. Of course, I know that the real solution here is to change the `uname -r` in the osver method to `ver` for windows, but if I want to have something like: def run_some_command(cmd) `cmd` end and the user specifies a bogus command, then the thing will just hang... of course I know about the obvious security holes here... Phil