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
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
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
Alle Thursday 02 October 2008, Bikas De simex ha scritto:
Are you aware that string interpolation doesn’t happen in single quoted
which, I guess, is what you want. To achieve this, you need to use a
following:
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:
Alle Thursday 02 October 2008, Bikas De simex ha scritto:
Are you aware that string interpolation doesn’t happen in single quoted
which, I guess, is what you want. To achieve this, you need to use a
following:
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:
Alle Thursday 02 October 2008, Bikas De simex ha scritto:
Are you aware that string interpolation doesn’t happen in single quoted
which, I guess, is what you want. To achieve this, you need to use a
following:
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:
This is because the argument array is passed as-is to the child process.
There is no shell performing line splitting. This eliminates a number of
potential errors and security holes, e.g. if dirc[3] contains spaces,
quotes, or other special characters subject to interpretation by the
shell.
rubee.rb:25: private method `chomp’ called for [“basetest\n”]:Array
(NoMethodError)
As Brian already pointed it’s String#chomp not Array#chomp.
String#lines gives you an Enumerable::Enumerator.
Your range index will give you an Array:
$filename = rio(‘some.txt’).lines[0…0] #=> [“basetest\n”]
If you just want “basetest\n” then use:
$filename = rio(‘some.txt’).lines[0] #=> “basetest\n”
or
$filename = rio(‘some.txt’).lines.first #=> “basetest\n”
Cmon, you will get it, if you read the error message carefully.
Try your code in irb and then ask your objects with inspect()
or class() what they really are, maybe you have not the object
you thought.