diff options
-rwxr-xr-x | ruby/named-pipe-a.rb | 12 | ||||
-rwxr-xr-x | ruby/named-pipe-b.rb | 8 |
2 files changed, 20 insertions, 0 deletions
diff --git a/ruby/named-pipe-a.rb b/ruby/named-pipe-a.rb new file mode 100755 index 0000000..23e260c --- /dev/null +++ b/ruby/named-pipe-a.rb @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby + +`mkfifo #{ARGV[0]}` +f = File.new "#{ARGV[0]}", 'w' + +while line = STDIN.gets + f.write line+"\n" + f.flush +end + +`rm #{ARGV[0]}` + diff --git a/ruby/named-pipe-b.rb b/ruby/named-pipe-b.rb new file mode 100755 index 0000000..0ea2f61 --- /dev/null +++ b/ruby/named-pipe-b.rb @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby + +f = File.new ARGV[0], 'r' + +while line = f.gets + puts line +end + |