Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #7400

Re: editing file in ruby

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.ruby
Subject Re: editing file in ruby
Date Mon, 23 Jul 2018 22:41:29 +0200
Lines 27
Message-ID <frmsrqF64frU1@mid.individual.net> (permalink)
References <7df54206-cde1-4dc7-a66c-190f0dc892a8@googlegroups.com> <04a7aba2-d2ee-4e59-95d4-462a2994863d@googlegroups.com> <frh533Fra2tU1@mid.individual.net> <1f224d79-40a4-469a-aa64-57feeb966e01@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net v4omp2942LZVgGwb3GtVOgAImS8Q5VkniaSbXH0WqPd+RyZO4=
Cancel-Lock sha1:6ezBZTlHtXL1RlHD00x7p3QJMnM=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
In-Reply-To <1f224d79-40a4-469a-aa64-57feeb966e01@googlegroups.com>
Content-Language en-US
Xref csiph.com comp.lang.ruby:7400

Show key headers only | View raw


On 22.07.2018 21:51, Mohan Mohta wrote:

> Thanks for your response.

You are welcome.  But I am not sure you understood my point:

> Here is what I did which worked.
> The conclusion I drew was when I opened the /tmp/bootfile file and yes the closing as well
> so if I opened with before grub.conf it worked

The issue is not the order of open operations but that you did not close 
file_boot at all.

> 	file_boot=File.open("/tmp/bootfile","w")
> [...] > 	file_boot.close

You better use the block form of File.open because it is way more robust 
than what you are doing here.

Cheers

	robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Back to comp.lang.ruby | Previous | NextPrevious in thread | Find similar


Thread

editing file in ruby mohan.mohta@gmail.com - 2018-07-19 14:49 -0700
  Re: editing file in ruby Mohan Mohta <mohan.mohta@gmail.com> - 2018-07-21 08:33 -0700
    Re: editing file in ruby Robert Klemme <shortcutter@googlemail.com> - 2018-07-21 18:25 +0200
      Re: editing file in ruby Mohan Mohta <mohan.mohta@gmail.com> - 2018-07-22 12:51 -0700
        Re: editing file in ruby Robert Klemme <shortcutter@googlemail.com> - 2018-07-23 22:41 +0200

csiph-web