bug in ruby or bug in my brain?

N

ngoc

#!/usr/bin/ruby
diff_file = File.open('diff.txt')
diff_file.each { |line|
next if line =~ /^Only/
system "dos2unix #{line.split(' and ').at(1).sub(' differ', '')}"
}
->work well

-------------------
#!/usr/bin/ruby
diff_file = File.open('diff.txt')
diff_file.each { |line|
next if line =~ /^Only/
system("dos2unix", line.split(' and ').at(1).sub(' differ', ''))
}
->problems with converting error message
 
Y

Yukihiro Matsumoto

Hi,

I don't know but both caused an exception on my box by using random
diff.txt file.

In message "Re: bug in ruby or bug in my brain?"
|
|#!/usr/bin/ruby
|diff_file = File.open('diff.txt')
|diff_file.each { |line|
| next if line =~ /^Only/
| system "dos2unix #{line.split(' and ').at(1).sub(' differ', '')}"
|}
|->work well
|
|-------------------
|#!/usr/bin/ruby
|diff_file = File.open('diff.txt')
|diff_file.each { |line|
| next if line =~ /^Only/
| system("dos2unix", line.split(' and ').at(1).sub(' differ', ''))
|}
|->problems with converting error message
 
N

ngoc

Yukihiro said:
Hi,

I don't know but both caused an exception on my box by using random
diff.txt file.
My box is Redhat Enterprise Workstation 3.0
Ruby 1.6.8 is already installed in Redhat

My diff.txt is generated when using diff command in linux.
Its output is: Files catalogue_1/A.txt and catalogue_2/A.txt differ
So I use Ruby to pick "catalogue_2/A.txt" out of that string and convert
the file to unix format. (A.txt from server is downloaded to a linux and
a windows machine, after that I want to check A.txt is the same. But it
differs because linux and windows has different ending. So I have to
convert windows ending to unix ending).
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top