Windows help/pipes/thread

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
   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

===============================================================================

A possible suggestion:
Maybe use sockets?

Regards

happen to be reading about that now... :wink:

the thing with pipes is testing can be done like

   ~ > cat test_stdin > pipe

which is __extremely__ handy for testing.

-a

···

On Wed, 21 Sep 2005, christophe.poucet@gmail.com wrote:

A possible suggestion:
Maybe use sockets?

--

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

===============================================================================

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'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

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

telnet localhost 1234 < test_stdin

Ha, killed another useless cat! :slight_smile:

Kind regards

    robert

···

christophe.poucet@gmail.com 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

···

On Wed, 21 Sep 2005, christophe.poucet@gmail.com 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

--

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

===============================================================================

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

You mean String#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)

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

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.

  RCR 313: rjust, ljust, center split on seperator

T.