From c2ade58bb868e72ba560553b3f72188453c55e7a Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Thu, 18 Aug 2016 10:24:56 +0200 Subject: ruby: named-pipe --- ruby/named-pipe-a.rb | 12 ++++++++++++ ruby/named-pipe-b.rb | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100755 ruby/named-pipe-a.rb create mode 100755 ruby/named-pipe-b.rb (limited to 'ruby') 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 + -- cgit v1.2.3