< :the previous in number
^ :the list in numerical order
> :the next in number
P :the previous aricle (the previous thread)
N :the next (in thread)
|<:the previous thread
>|:the next thread
^ :the parent (reply-to)
_:the child (an article replying to this)
>:the elder article having the same parent
<:the youger article having the same parent
---:split window and show thread lists
| :split window (vertically) and show thread lists
~ :close the thread frame
.:the index
..:the index of indices
Was writting a script to poll an audiotron (www.audiotron.net) and
record a list of the music that has been played.
The audiotron has an internal webserver so I used the net/http package.
The script runs fine for a while, but after about the 11th pass it falls
over with the following error:
I:/development/ruby/lib/ruby/1.7/net/protocol.rb:501:in `sysread': Bad
file descriptor (Errno::EBADF)
from I:/development/ruby/lib/ruby/1.7/net/protocol.rb:501:in `rbuf_fill'
from I:/development/ruby/lib/ruby/1.7/net/protocol.rb:443:in `read'
from I:/development/ruby/lib/ruby/1.7/net/http.rb:1520:in `read_chunked'
from I:/development/ruby/lib/ruby/1.7/net/http.rb:1494:in `read_body_0'
from I:/development/ruby/lib/ruby/1.7/net/http.rb:1477:in `read_body'
from I:/development/ruby/lib/ruby/1.7/net/http.rb:1463:in `reading_body'
from I:/development/ruby/lib/ruby/1.7/net/http.rb:780:in `request'
from I:\ruby stuff\audiotron-play-watcher.rb:37
from I:\ruby stuff\audiotron-play-watcher.rb:36:in `start'
from I:\ruby stuff\audiotron-play-watcher.rb:36
I'm puzzeled as to what the problem is. The page is always there, if
will update if continually refreshed in a browser without a problem.
What file descriptor is being referred to here?
Anyone have any thoughts or comments?
TIA
Rob
<<<<<<<<<<<<<<<Attached below is the code>>>>>>>>>>>>>>>>>>>
require 'english'
require 'net/http'
require 'log4r'
include Log4r
# set up logger
atlog = Logger.new 'atlog'
outputter = FileOutputter.new( atlog, { 'filename', './at.log', 'trunc',
false } )
outputter.formatter = PatternFormatter.new :pattern => "[%l] %d :: %m"
atlog.outputters = outputter
# set up connection details for audiotron
req = Net::HTTP::Get.new('apigetstatus.asp')
address = Net::HTTP.new('atron00427c', 80)
req.basic_auth 'admin','admin'
response = nil
previousFile = nil
currentFile = nil
currentArtist = nil
currentAlbum = nil
currentTrack = nil
currentGenre = nil
currentPlayStyle = nil
currentTrackLength = 0
queueLength = 0
currentIndex = 0
passes = 0
while true
atlog.debug("Pass #{passes}")
passes += 1
address.start { |http|
response = http.request(req) # <<<---- problem line
}
response.body.each { | line |
if line =~ /TotalTime=/
currentTrackLength = $POSTMATCH
elsif line =~ /RANDOM_LED=/
if $POSTMATCH
currentPlayStyle = "random"
else
currentPlayStyle = "ordered"
end
elsif line =~ /^Title=/
currentTrack = $POSTMATCH.chomp
elsif line =~ /^Artist=/
currentArtist = $POSTMATCH.chomp
elsif line =~ /^Album=/
currentAlbum = $POSTMATCH.chomp
elsif line =~ /^Genre=/
currentGenre = $POSTMATCH.chomp
elsif line =~ /^SourceID=/
currentFile = $POSTMATCH.chomp
elsif line =~ /^QueueLen=/
queueLength = $POSTMATCH.chomp
elsif line =~ /^CurrIndex=/
currentIndex = $POSTMATCH.chomp
end
}
if currentFile != previousFile
atlog.info("Playing track #{currentIndex} of #{queueLength} in a
#{currentPlayStyle} way\n" +
"#{currentTrack} by #{currentArtist} on #{currentAlbum} is
#{currentTrackLength} seconds long\n" +
"File is :- #{currentFile}\n")
previousFile = currentFile
end
currentFile = nil
currentTrack = nil
currentArtist = nil
currentAlbum = nil
currentGenre = nil
currentPlayStyle = nil
currentTrackLength = nil
queueLength = 0
currentIndex = 0
response = nil
sleep 5
end