From: Craig Files Date: 2002-02-15T04:59:23+09:00 Subject: Re: File.open weirdness In article , "David Alan Black" wrote: > Hello -- > > On Fri, 15 Feb 2002, Craig Files wrote: > >> Hi, >> I need some help figuring out why the following ruby code does not >> work. >> >> ruby: >> File.open("test.cmd",0666,File::CREAT|File::TRUNC|File::WRONLY){ |file| >> file.puts("Write something in the file\n") file.puts("Write >> something else in the file\n") >> } >> File.open("test.cmd",0666,File::CREAT|File::TRUNC|File::WRONLY){ |file| >> file.puts("Write something in the file\n") >> } > > Put the permissions after the mode :-) > > > David > Thanks, this is contrary to the information in the "Programming Ruby" book, where the example for File.new shows the permissions before the mode. Now the problem is:File.open("test.cmd",File::CREAT|File::TRUNC|File::WRONLY,0666){ |file| ..... } Still does not get the permissions correct: > ls -l test.cmd -rw-rw-r-- 1 cfiles fiddms 32 Feb 14 12:47 test.cmd not -rw-rw-rw Craig