execuate command problem

M

Martin Sharon

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!
 
R

Robert Klemme

2009/4/27 Martin Sharon said:
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
 
M

Martin Sharon

Works for me

17:03:46 bin$ ruby <<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
 
A

Alex Eiras

[Note: parts of this message were removed to make it a legal post.]

Works for me

17:03:46 bin$ ruby <<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
line = f.gets.chomp to remove carriage return.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,489
Latest member
BrigidaD91

Latest Threads

Top