From: Stefano Crocco Date: 2008-10-02T01:10:42+09:00 Subject: Re: Remotely passing value on system() or %x[] Alle Wednesday 01 October 2008, Bikas De simex ha scritto: > Hi, > > I want to execute a remote bash script that take one string argument by > using system() or %x[]. But the value argument is not transmited > remotely. > > Here my program > > def trait_fic(repfic) > Find.find(repfic) do |path| > unless FileTest.directory?(path) > dirc="#{path}".split(/\//) > puts "#{dirc[3]}\n" > system('plink -pw ppp xxx@yyyy /tmp/essai.ksh #{dirc[3]}') > end > end > end > > trait_fic('I:/toto') > > I have got: > >ruby essai0.rb > > PTOTO -------------------------> This is done by puts "#{dirc[3]}\n" > <--- > Le batch traité est > > .......................... > > /tmp/mma/essai.ksh[36]: syntax error at line 214 : `"Nous traitons le > batch $BATH ...n"' unexpected > > Is there any way to transmit remotely this value. I also try net/ssh > with no succes. > Thanks in Advance Are you aware that string interpolation doesn't happen in single quoted strings? Since argument to system is a string enclosed in single quotes, the command itself is 'plink -pw ppp xxx@yyyy /tmp/essai.ksh #{dirc[3]}' instead of 'plink -pw ppp xxx@yyyy /tmp/essai.ksh PTOTO' which, I guess, is what you want. To achieve this, you need to use a double quoted string: system("plink -pw ppp xxx@yyyy /tmp/essai.ksh #{dirc[3]}") I hope this helps Stefano