From: Moritz Reiter Date: 2007-01-03T05:50:12+09:00 Subject: Re: "su user -c 'command'" from within ruby ara.t.howard@noaa.gov wrote: >> pid = %x{pgrep -f #{pattern}} >> %x{kill #{pid}} if pid != 0 and pid != nil and pid != "" > > # > # use Process.kill > # > >> >> cmd = "su #{USER} -c \"ssh -f -N -L \ >> #{port}:#{@site.synergy_server}:#{port} #{@site.synergy_server}\"" > > # > # use Net::SSH > # That makes me look like a complete newbie, eh? Actually I am. So thanks for the hints! :) >> >> # this one gets executed but nothing afterwards... >> %x{#{cmd}} > > this is probably blocking and asking for password. perhaps you don't have > keys or your agent running properly? because you are using backticks/%x > any > stdout, such as a password prompt, will be lost. just by changing this to > 'system' you should be able to see if this is the case. > > in any case i'm guessing this is a env/ssh issue rather than a ruby one. It works when I use 'system' instead of %x{} but it doesn't prompt for a password either. I have the public ssh keys exchanged. So it most probably is an environment issue. In any case: You helped me a lot, thank you! Regards, Moritz