Stefano Crocco
10/2/2008 12:55:00 PM
Alle Thursday 02 October 2008, Bikas De simex ha scritto:
> Stefano Crocco wrote:
> > Alle Wednesday 01 October 2008, Bikas De simex ha scritto:
> >> unless FileTest.directory?(path)
> >>
> >> >ruby essai0.rb
> >>
> >> 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
>
> Ruby refused to interpolate #{dirc[3]} dispite I have tried the
> following:
>
> system("plink -pw ppp xxx@yyyy /tmp/essai.ksh #{dirc[3]}")
> system('plink -pw ppp xxx@yyyy /tmp/essai.ksh "#{dirc[3]}"')
> system("plink -pw ppp xxx@yyyy /tmp/essai.ksh '#{dirc[3]}'")
> system(plink '-pw ppp xxx@yyyy /tmp/essai.ksh #{dirc[3]}')
> system(plink "-pw ppp xxx@yyyy /tmp/essai.ksh #{dirc[3]}")
> system('plink -pw ppp xxx@yyyy /tmp/essai.ksh #{dirc[3]}')
>
> Any suggestion please !
>
> Thanks in advance.
The third line should work. To be sure the falut is of missing interpolation,
I'd suggest to break the call to system in two steps: first, build the command
string, then call puts. While this shouldn't affect the result, it allows you
to see which is the command you're going to execute with system. You can do
something like this:
cmd = "plink -pw ppp xxx@yyyy /tmp/essai.ksh #{dirc[3]}"
puts cmd
system(cmd)
What's the output from the lines above?
Stefano