print messages show up after script has quit

Discussion in 'Ruby' started by stan, Apr 25, 2007.

  1. stan

    stan Guest

    Hello,

    I use ruby 1.8.6 on windows xp sp2. My script updates podcast
    subsrciptions at night.This saves internet traffic during the day. It
    starts iTunes application, sleeps while itunes updates feeds and then
    quits.

    Here's listing

    require 'win32ole'


    #starts itunes application and updates podcasts
    ready = Time.local(2007, "Apr", 25, 15, 05, 1)
    done = false
    while !done do

    now = Time.now

    if now > ready then
    itunes = WIN32OLE.new('iTunes.Application')
    if itunes then
    print "Update started\n"
    itunes.UpdatePodcastFeeds
    sleep 30 # waits 30 secs

    itunes.Quit
    print "shutdown...\n"
    done=true
    end
    else
    print "Not so fast boy..." + now.to_s() + "\n"
    sleep(30) # waits for 30 secs
    end
    end



    While testing I noted that any debug output I print shows up in a
    window after the applicaiton has quit. I don't know why it is
    happening, because obviously I want script to print messages to see
    its activity. Any help appreciated.

    Thanks
     
    stan, Apr 25, 2007
    #1
    1. Advertising

  2. stan

    Guest

    > Hello,
    >
    > I use ruby 1.8.6 on windows xp sp2. My script updates podcast
    > subsrciptions at night.This saves internet traffic during the day. It
    > starts iTunes application, sleeps while itunes updates feeds and then
    > quits.


    This is happening because stdout is buffered.

    Text written to stdout will appear once the buffer is full, when the
    program ends or if you ask for the buffer to be flushed by calling
    $stdout.flush like this:

    > else
    > print "Not so fast boy..." + now.to_s() + "\n"

    $stdout.flush # flush stdout
    > sleep(30) # waits for 30 secs
    > end


    Kristian
     
    , Apr 25, 2007
    #2
    1. Advertising

  3. schrieb:

    > This is happening because stdout is buffered.
    >
    > Text written to stdout will appear once the buffer is full, when the
    > program ends or if you ask for the buffer to be flushed by calling
    > $stdout.flush like this:


    Correct me if I'm wrong, but I thought flushing would be implicit
    whenever a newline ('\n') is printed.
     
    Björn Paetzel, Apr 25, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Segall

    Where to after Exit/Quit/Logout?

    David Segall, Jan 4, 2006, in forum: HTML
    Replies:
    3
    Views:
    374
  2. kk
    Replies:
    6
    Views:
    578
    Hendrik van Rooyen
    Aug 15, 2009
  3. Tom Petersen
    Replies:
    0
    Views:
    146
    Tom Petersen
    Nov 17, 2003
  4. John B. Matthews
    Replies:
    0
    Views:
    760
    John B. Matthews
    Dec 9, 2011
  5. Roedy Green
    Replies:
    5
    Views:
    2,320
    Gene Wirchenko
    Dec 13, 2011
Loading...

Share This Page