windows help/pipes/thread

Discussion in 'Ruby' started by Ara.T.Howard, Sep 20, 2005.

  1. Ara.T.Howard

    Ara.T.Howard Guest

    can someone tell me the behaviour of these two programs run in separate
    terminals under windows?

    harp:~ > cat a.rb
    system "mkfifo fifo >/dev/null 2>&1" # don't know how to do this in win
    File::chmod 0777, "fifo"

    t0 =
    Thread::new do
    loop do
    open("fifo", File::RDONLY|File::NONBLOCK) do |fifo|
    f = select([fifo]).first.first
    STDERR.print f.read
    end
    end
    end

    t1 =
    Thread::new do
    loop do
    STDERR.puts 42
    sleep 0.42
    end
    end

    gets


    harp:~ > cat b.rb
    loop do
    open("fifo", File::WRONLY) do |f|
    f.puts 'forty-two'
    end
    sleep 0.42
    end


    i expect the output to look something like:

    42
    42
    42
    42
    42
    forty-two
    42
    forty-two
    42
    forty-two
    42
    forty-two
    ...
    ...


    cheers.

    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | Your life dwells amoung the causes of death
    | Like a lamp standing in a strong breeze. --Nagarjuna
    ===============================================================================
    Ara.T.Howard, Sep 20, 2005
    #1
    1. Advertising

  2. Ara.T.Howard

    Guest

    A possible suggestion:
    Maybe use sockets?

    Regards
    , Sep 20, 2005
    #2
    1. Advertising

  3. Ara.T.Howard

    Ara.T.Howard Guest

    On Wed, 21 Sep 2005, wrote:

    > A possible suggestion:
    > Maybe use sockets?


    happen to be reading about that now... ;-)

    the thing with pipes is testing can be done like

    ~ > cat test_stdin > pipe

    which is __extremely__ handy for testing.

    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | Your life dwells amoung the causes of death
    | Like a lamp standing in a strong breeze. --Nagarjuna
    ===============================================================================
    Ara.T.Howard, Sep 20, 2005
    #3
  4. Ara.T.Howard

    Guest

    What you could do is make a simple program "pipe" that forwards to the
    given socket.

    Then you could do something like.

    cat test_stdin | pipe localhost 1234
    , Sep 20, 2005
    #4
  5. wrote:
    > What you could do is make a simple program "pipe" that forwards to the
    > given socket.
    >
    > Then you could do something like.
    >
    > cat test_stdin | pipe localhost 1234


    s/pipe/telnet/ - works even on Windows boxes. :) And while we're at it,
    then you should also be able to do

    telnet localhost 1234 < test_stdin

    Ha, killed another useless cat! :)

    Kind regards

    robert
    Robert Klemme, Sep 20, 2005
    #5
  6. Ara.T.Howard

    Ara.T.Howard Guest

    On Wed, 21 Sep 2005, wrote:

    > What you could do is make a simple program "pipe" that forwards to the
    > given socket.
    >
    > Then you could do something like.
    >
    > cat test_stdin | pipe localhost 1234


    i guess the idea is out since windows does not support AF_LOCAL ;-( tcp would
    be __way__ too slow.

    -a
    --
    ===============================================================================
    | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
    | phone :: 303.497.6469
    | Your life dwells amoung the causes of death
    | Like a lamp standing in a strong breeze. --Nagarjuna
    ===============================================================================
    Ara.T.Howard, Sep 20, 2005
    #6
  7. Class: String align_center

    I'm trying to use the align_center method for the String class and it
    never works as shown below. Any ideas?

    http://nano.rubyforge.org/doc/classes/String.html

    Code:
    k = String.new("hello").align_center(14)

    Error:
    c:/cronjobs/test.rb:1: undefined method `align_center' for
    "hello":String (NoMethodError)

    Thanks,
    Charles
    Charles Leeds, Sep 20, 2005
    #7
  8. Re: Class: String align_center

    Hmm. Appears this isn't base Ruby functionality. My bad. I will have
    to learn how to implement Nano in Rails.

    Charles Leeds wrote:

    > I'm trying to use the align_center method for the String class and it
    > never works as shown below. Any ideas?
    >
    > http://nano.rubyforge.org/doc/classes/String.html
    >
    > Code:
    > k = String.new("hello").align_center(14)
    >
    > Error:
    > c:/cronjobs/test.rb:1: undefined method `align_center' for
    > "hello":String (NoMethodError)
    >
    > Thanks,
    > Charles
    >
    >
    >
    >
    Charles Leeds, Sep 20, 2005
    #8
  9. Ara.T.Howard

    Eric Hodel Guest

    Re: Class: String align_center

    On 20 Sep 2005, at 14:34, Charles Leeds wrote:

    > I'm trying to use the align_center method for the String class and
    > it never works as shown below. Any ideas?
    >
    > http://nano.rubyforge.org/doc/classes/String.html
    >
    > Code:
    > k = String.new("hello").align_center(14)
    >
    > Error:
    > c:/cronjobs/test.rb:1: undefined method `align_center' for
    > "hello":String (NoMethodError)


    You mean String#center.

    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    Eric Hodel, Sep 20, 2005
    #9
  10. Ara.T.Howard

    Trans Guest

    Re: Class: String align_center

    > You mean String#center.

    True. #align_center is a Nano method. It differs from the built-in
    #center in that it will center each line of a string (or any split for
    that matter), not just the whole string as a single unit.

    BTW, I thought it would be better if #center embraced this
    functionality too, so I put in an RCR for it, but haven't yet heard if
    it will be accepted.

    http://www.rcrchive.net/rcr/show/313

    T.
    Trans, Sep 21, 2005
    #10
    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. piyush
    Replies:
    0
    Views:
    1,844
    piyush
    Jul 14, 2004
  2. Paul

    Windows Pipes

    Paul, Nov 25, 2003, in forum: Java
    Replies:
    1
    Views:
    1,397
  3. piyush
    Replies:
    1
    Views:
    3,158
    John Harrison
    Jul 14, 2004
  4. piyush
    Replies:
    0
    Views:
    456
    piyush
    Jul 14, 2004
  5. David H
    Replies:
    0
    Views:
    478
    David H
    Dec 3, 2004
Loading...

Share This Page