Hey,
I’m working on script using Watir class where I want to pass variable of
Watir class to another script and I’m getting an error saying "syntax of
the command is invalid’, but when I pass any other variable it works
fine.
Here is my code
Working ex.
main.rb:
$test = ‘test’
system(“ruby “popi.rb” #{$test}”)
Am Donnerstag, 20. Sep 2007, 23:06:07 +0900 schrieb Michal S.:
I’m working on script using Watir class where I want to pass variable of
Watir class to another script and I’m getting an error saying "syntax of
the command is invalid’, but when I pass any other variable it works
fine.
Not working ex.
main.rb:
require ‘watir’
$ie = Watir::IE.attach(:title,/Appli.*/)
system(“ruby “popi.rb” #{$ie}”)
This is not a Ruby but a shell issue. Use
system “ruby”, “popi.rb”, $ie
Further, command arguments may only be strings. If you
really need to do this anyway you could marshal the object:
----sub.rb
class C ; end
c = Marshal.load ARGV.shift
puts c.inspect
Further, command arguments may only be strings. If you
really need to do this anyway you could marshal the object:
What I just noticed was that it throws me an error saying that $ie
cannot be converted to string. Why is trying to convert it to string if
it’s the 1st arg.?
I don’t follow that logic here…
Am Freitag, 21. Sep 2007, 22:17:22 +0900 schrieb Michal S.:
system “ruby”, “popi.rb”, $ie
What I just noticed was that it throws me an error saying that $ie
cannot be converted to string. Why is trying to convert it to string if
it’s the 1st arg.?
That was what I meant when I wrote this:
I doubt whether objects that are connected to processes
outside could be marshalled at all.
Arguments to Unix commands are always strings; return value
is always a 1-byte integer where 0 means success.
Bertram
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.