Execuate command problem

I want to execute a shell command in ruby, like this:

line = "tokyo paris london"
par = "23 23 11 43"
execute = "./comp #{line} #{par}"
puts execute

but the command executed is

./comp tokyo paris london
23 23 11 43

There is an "enter" there, how can I execute:

./comp tokyo paris london 23 23 11 43

without line changing?

thanks!

···

--
Posted via http://www.ruby-forum.com/.

I want to execute a shell command in ruby, like this:

line = "tokyo paris london"
par = "23 23 11 43"
execute = "./comp #{line} #{par}"
puts execute

but the command executed is

./comp tokyo paris london
23 23 11 43

There is an "enter" there, how can I execute:

./comp tokyo paris london 23 23 11 43

without line changing?

Works for me

17:03:46 bin$ ruby <<XX

line = "tokyo paris london"
par = "23 23 11 43"
execute = "./comp #{line} #{par}"
puts execute
XX

./comp tokyo paris london 23 23 11 43
17:12:42 bin$

You must have been doing something differently than posted.

Kind regards

robert

···

2009/4/27 Martin Sharon <huangshuo.9@gmail.com>:

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Works for me

17:03:46 bin$ ruby <<XX

line = "tokyo paris london"
par = "23 23 11 43"
execute = "./comp #{line} #{par}"
puts execute
XX

./comp tokyo paris london 23 23 11 43
17:12:42 bin$

You must have been doing something differently than posted.

Kind regards

robert

Oh, I think the only difference is in my program

f=File.open(ARGV[0], 'r')
line= f.gets

···

--
Posted via http://www.ruby-forum.com/\.

line = f.gets.chomp to remove carriage return.

Cheers

···

On Mon, Apr 27, 2009 at 5:20 PM, Martin Sharon <huangshuo.9@gmail.com>wrote:

>
> Works for me
>
> 17:03:46 bin$ ruby <<XX
>> line = "tokyo paris london"
>> par = "23 23 11 43"
>> execute = "./comp #{line} #{par}"
>> puts execute
>> XX
> ./comp tokyo paris london 23 23 11 43
> 17:12:42 bin$
>
> You must have been doing something differently than posted.
>
> Kind regards
>
> robert

Oh, I think the only difference is in my program

f=File.open(ARGV[0], 'r')
line= f.gets

Alex Eiras wrote:

···

On Mon, Apr 27, 2009 at 5:20 PM, Martin Sharon > <huangshuo.9@gmail.com>wrote:

> 17:12:42 bin$
line= f.gets

line = f.gets.chomp to remove carriage return.

Cheers

...it works! thank you!
--
Posted via http://www.ruby-forum.com/\.