Exec with string in variables?

Hi,

i have something like this and more in perl and would transform it to
ruby.
First i changed system to exec and than the points to plus , but the
strings which are in the scalar’s seems
not be applied in the exec call , perhaps some special needs with
quoting!?

:perl
foreach $line(@methoden) {
system("$exe_path" . “dti.exe -qb -t -e$line $dom_file
$train_file $modell_string” . “$line” . “.dti”);

}

:ruby

methoden.each do |line|
exec(“exe_path + dti.exe -qb -t -eline dom_file train_file
modell_string + line + .dti”)

end

many thanks christian

Try

exec("#{exe_path dti.exe -qb -t -eline #{dom_file} #{train_file}
#{modell_string} #{line} .dti")

Ruby needs #{variable} in quotes to parse variable. Or you could
concatenate outside the quotes like:

exec(exe_path + “dti.exe -qb…” + dom_file)

Basically, it is variable + “string” + another_variable
On Tue, 2007-04-17 at 23:55 +0900, Christian wrote:

:perl
modell_string + line + .dti")

end

many thanks christian

Thanks,

Ken M.
Wireless Operations Engineer
Farmers Wireless

CONFIDENTIALITY NOTICE: This e-mail and any attachment to it may contain
confidential and legally privileged information. This information is
intended only for the recipient named above. If you are not the intended
recipient, take notice that any disclosure, copying, distribution or
taking of any action based upon this information is prohibited by law.
If you have received this e-mail in error, please return it to the
sender and delete this copy from your system. Thank you.

On Apr 17, 10:53 am, Christian [email protected] wrote:

foreach $line(@methoden) {


end

many thanks christian

String interpolation does this nicely:

methoden.each do |line|
exec(“#{exe_path}dti.exe -qb -t -e#{line} #{dom_file} #{train_file}
#{modell_string}#{line}.dti”)

end

On Tue, Apr 17, 2007 at 11:55:06PM +0900, Christian wrote:

:perl
foreach $line(@methoden) {
system("$exe_path" . “dti.exe -qb -t -e$line $dom_file
$train_file $modell_string” . “$line” . “.dti”);

}

Instead of $var write #{var}

Alternatively, let Ruby deal with the individual arguments:

system(exe_path, “-qb”, “-t”, “-e” + line, dom_file, train_file,
modell_string + line + “.dti”)

This is safer as it will work even if the arguments themselves contain
spaces.