$:.unshift File.dirname(__FILE__) require 'drbssh' # local version of drbssh sudo gem install drbssh class Ohmy def toto puts 'i am '+`hostname` return 'i am '+`hostname` end end # Connect - OK DRb.start_service 'drbssh://' remote = DRbObject.new_with_uri("drbssh://_sd/ruby") # Simple eval - OK puts remote.eval('`hostname`') puts remote.eval('1+1') # Send classobj - FAIL #o = DRbObject.new_with_uri "drbssh://_sd/ruby", Ohmy.new #Ohmy.new #o = remote.eval("Ohmy.new") #class << remote # undef :instance_eval # def bla # puts 'i am '+`hostname` # end #end #remote.bla # Create objects - OK #l = Hash #l2 = DRbObject.new(l, "drbssh://_sd/ruby") #remote_hash = remote.eval("@a = {}.extend(DRb::DRbUndumped)") #puts l2 #remote_hash = remote.eval("@a = {}.extend(DRb::DRbUndumped)") # Send object - OK l = [1,2,3] obj = remote.eval("@data = \""+Marshal.dump(l)+"\"") obj = remote.eval("@a = Marshal.load(@data)") obj = remote.eval("@a += [4]") obj += [5] puts obj # Send class object - FAIL #o = Ohmy.new #eval("puts o.toto") #eval("puts Ohmy.new.toto") #eval("@c = \"Marshal.dump(Ohmy)\"; @d=Marshal.load(eval(@c))") #eval("@d.new.toto") #obj = remote.eval("@c = \""+Marshal.dump(Ohmy)+"\"") #puts obj #obj = remote.eval("@c.class") #puts obj #obj = remote.eval("@c.size") #puts obj #obj = remote.eval("@cc = Marshal.load(eval(@c))") #puts obj #obj = remote.eval("@o = @cc.new.toto") #puts obj #obj = remote.eval("@obj = @o.toto") #puts obj #obj = remote.eval("@obj = \""+Marshal.dump(o)+"\"") #puts obj #obj = remote.eval("puts Ohmy.new.toto") #puts obj