Re: Getting this to Work

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hi,

I think the problem is that you have the "-b" option in the wget invocation.
The fact that wget has successfully created the file doesn't mean that he have
already downloaded all the page.
I removed the "-b" option from the command line and now it works. 

In order to give two seconds to wget to download the file i've changed
your code like this:

without warning

include uniquefn.e

constant CLOCK_PER_SEC=10000

global function getRSSFeed( sequence url )
sequence result, sys, lines
object fname, fn, line
atom timer, delta

  result = ""
  fname = uniquefn("")
  
  sys = "wget -q -b -O " & fname & " -o " & "wget.log " & url
  fn = system_exec(sys,2)
  
  delta = 2 / CLOCK_PER_SEC
  timer = time() + delta
  while time() < timer do
    -- give it two seconds to open the file
    -- no op
  end while

  fn = open(fname,"r")
  
  if fn > 0 then -- opened the file
    lines = ""
    line = gets(fn)
    while sequence(line) do
      lines &= line
      line = gets(fn)
    end while
    close(fn)
    if length(lines) > 0 then
      result = "Success from " & fname & ":\n" & lines
    else
result = "Failed to get anything from " & fname & " (fn = " &
      sprintf("%d",{fn}) & ")"
    end if
  else
    result = "Failed to open file " & fname
  end if
  return result
end function

puts(1,getRSSFeed("http://www.listfilter.com/EUforum/messages.xml"))


Leonardo

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu