Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8403527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:22:05+00:00 2026-06-09T22:22:05+00:00

I’m writing a sinatra app in ruby that gathers information about my network into

  • 0

I’m writing a sinatra app in ruby that gathers information about my network into two different files. The first, a .csv, gathers information on the IP Addresses and given names of all workstations in the network. The second, a .txt, reads into an Asterisk server and gathers information on active SIP channels linking to specified IP Addresses.

My app is merely compiling the information from these two files and creating tables on a webpage matching up users currently logged into specific stations. However, I want the app to feign realtime-use. I have the two files being automatically updated every 5 minutes, but as the files being read by the app are being overwritten, the app’s output doesn’t change. Is there a way to rig it so the app is reading the “new” files after they are written?

I’ve dug around on stack overflow, and I’ve seen things mentioning Kqueue for python users to simply watch for changes in those files before rewriting them, which would be really nice. Is there a ruby version for that? Additionally, I want the app to be accessible at all times, and maybe only “refresh” when it needs to update something, so that would make sense.

I also came to a funny little epiphany when I realized I’m never closing my files after I read them. I won’t post the whole app, but here’s where I read the files:

#Pulls active SIP channels from Asterisk
$sip = {}
File.open('sip.txt').each do |line|
  userid,ip = line.split(" ")
  $sip[ip] = userid[0..3]
end

#Prepares hash of all stations, ip addresses
$machines = {}
CSV.foreach('/Volumes/Scripts/report-51.csv') do |row|
  name = row[1]
  address = row[0]
  $machines[name] = address
end

Is it possible that because I never close the files, the program never opens up the “new” documents? Just trying to brainstorm here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:22:06+00:00Added an answer on June 9, 2026 at 10:22 pm

    It’s hard to tell the overall structure of what’s going on, but yeah, whatever code is being called every 5 minutes and which in turn does the file reading, I would make sure that the files are closed and reopened in that code with every call. That should solve your problem.

    You may also consider switching to a database approach for more robust results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.