> ruby -e 'File.open("foo.txt","w") do |f|; f.write 6; end'
> 
> -e:1: parse error

Try it without the semi-colon after |f|? I dunno -- your version ran for me
(though I had to flip-flop the single and double quotes to get it through
cmd.com on Windows 2k:

C:\temp>ruby -e 'File.open("foo.txt","w") do |f|; f.write 6; end'
'f' is not recognized as an internal or external command,
operable program or batch file.

C:\temp>ruby -e "File.open('foo.txt','w') do |f|; f.write 6; end"

C:\temp>dir foo.txt
 Volume in drive C is MS-DOS_6
 Volume Serial Number is BCBF-0F2A

 Directory of C:\temp

05/22/2002  09:08a                   1 foo.txt
               1 File(s)              1 bytes
               0 Dir(s)     123,956,736 bytes free

C:\temp>ruby -e "File.open('foo.txt','w') do |f| f.write 6; end"

C:\temp>