# Works on my machine, not on his machine after he edits

**URL:** <https://www.ruby-forum.com/t/works-on-my-machine-not-on-his-machine-after-he-edits/140897>\
**Category:** Ruby\
**Created:** [June 19, 2008, 4:07pm UTC](https://www.ruby-forum.com/t/works-on-my-machine-not-on-his-machine-after-he-edits/140897 "2008-06-19T16:07:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![toadkicker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@toadkicker](https://www.ruby-forum.com/u/toadkicker)\
**Post date:** [June 19, 2008, 4:07pm UTC](https://www.ruby-forum.com/t/works-on-my-machine-not-on-his-machine-after-he-edits/140897/1 "2008-06-19T16:07:02Z")

</div>

This is weird. I have a script I’ve written to reformat a file for this  
guy. It works perfect on my Mac, but not on his.

This was a quick and dirty script to reformat an ascii file. It parses  
the fixed length records and writes the output in a tab delimited  
format. No big deal.

I had hard coded the file name in the script, and sent it to him, to  
edit and type in the correct path names for the input and output files,  
and now it does not work for him.

This is the error he gets:

Last login: Sat Jun 14 16:57:06 on console  
adam-fanns-power-mac-g5:~ adamfann$ cd desktop  
adam-fanns-power-mac-g5:desktop adamfann$ ruby phone\_nums.rb  
phone\_nums.rb:1: syntax error, unexpected tIDENTIFIER, expecting $end  
IO.foreawhen “S1if value[0,1]==”=" then value =  
value[1,value.length-1].to\_s ; eputs “…done.” ; Unknown record  
type:\n\t#{t}" ;

These are some of the lines in question from my copy of the source:

infile = “/Users/toddburch/Desktop/file.txt”  
outfile = “/Users/toddburch/Desktop/file\_converted.txt”

out = File.open(outfile, “w”) ;  
outdata = “” ;  
IO.foreach(infile) {|t|  
case t[0,3]  
when “S01” then  
if (outdata != “”) then out.puts outdata end  
outdata = t[15,7] ;  
when “S13” then outdata += ("\t" + t[12,1].to\_s) ;  
when “S14” then  
value = t[16,t.strip.length-2-16]  
if value[0,1]=="=" then value = value[1,value.length-1].to\_s ; end  
outdata += “\t” + value.to\_s ;  
else puts “Unknown record type:\n\t#{t}” ;  
end  
}

He’s using TextEdit to edit, and his Preferences are set for a plain  
text file. He’s sent me his copy after he edits it, and to the eye, it  
looks fine. I have to overtype his file names to run it on my machine,  
and after removing that, it works fine.

Any ideas?

Thanks, Todd (posted to Ruby Forum - I may not see your reply if you  
answer is directed another list)  
(By the way, the link to the FAQ is not working)

---

<div class="post-metadata">

**Author:** ![toadkicker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@toadkicker](https://www.ruby-forum.com/u/toadkicker)\
**Post date:** [June 19, 2008, 5:35pm UTC](https://www.ruby-forum.com/t/works-on-my-machine-not-on-his-machine-after-he-edits/140897/2 "2008-06-19T17:35:01Z")

</div>

On Jun 19, 10:08 am, Todd B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

Offhand it looks to me like there’s a problem with the script’s line  
endings, i.e. Ruby is expecting Unix line endings but the script has  
DOS endings. The clue is that the error message seems to be claiming  
that the error is on line 1, as though the entire script is one line.  
I don’t know why this would be a problem if both your computer and his  
are Macs, though.

---

<div class="post-metadata">

**Author:** ![toadkicker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@toadkicker](https://www.ruby-forum.com/u/toadkicker)\
**Post date:** [June 19, 2008, 5:46pm UTC](https://www.ruby-forum.com/t/works-on-my-machine-not-on-his-machine-after-he-edits/140897/3 "2008-06-19T17:46:09Z")

</div>

On 19 Jun., 17:29, Karl von Laudermann [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > IO.foreawhen “S1if value[0,1]==”=" then value =  
> > value[1,value.length-1].to\_s ; eputs “…done.” ; Unknown record  
> > type:\n\t#{t}" ;
> 
> Offhand it looks to me like there’s a problem with the script’s line  
> endings, i.e. Ruby is expecting Unix line endings but the script has  
> DOS endings. The clue is that the error message seems to be claiming  
> that the error is on line 1, as though the entire script is one line.  
> I don’t know why this would be a problem if both your computer and his  
> are Macs, though.

Another potential source might be different versions of the Ruby  
interpreter.

Cheers

robert

---

<div class="post-metadata">

**Author:** ![toadkicker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@toadkicker](https://www.ruby-forum.com/u/toadkicker)\
**Post date:** [June 19, 2008, 6:03pm UTC](https://www.ruby-forum.com/t/works-on-my-machine-not-on-his-machine-after-he-edits/140897/4 "2008-06-19T18:03:17Z")

</div>

Karl von Laudermann wrote:

> I don’t know why this would be a problem if both your computer and his  
> are Macs, though.

Right. I use TextWrangler and have my line-end setting to be Unix (LF).  
I just looked in TextEdit and it doesn’t even appear to have an option.

(I worked around the problem by writing a java program to do the same  
thing… ☹ )

---

<div class="post-metadata">

**Author:** ![toadkicker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/5fc32e/32.png) [@toadkicker](https://www.ruby-forum.com/u/toadkicker)\
**Post date:** [June 19, 2008, 8:16pm UTC](https://www.ruby-forum.com/t/works-on-my-machine-not-on-his-machine-after-he-edits/140897/5 "2008-06-19T20:16:47Z")

</div>

Robert K. wrote:

> Another potential source might be different versions of the Ruby  
> interpreter.

Could be, but that seems strange. Of course, the whole scenario is  
strange. He’s running:

ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]

and I’m running:

ruby 1.8.2 (2004-12-25) [universal-darwin8.0]

Todd
