summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2016-08-18 10:24:56 +0200
committerPatrick Simianer <p@simianer.de>2016-08-18 10:24:56 +0200
commitc2ade58bb868e72ba560553b3f72188453c55e7a (patch)
treee42b882ede08b7ecdce9c6b35a6a4dcdfe2089ab
parent43fcaa14840a18a4ab9e6ab9530933a6c60bd604 (diff)
ruby: named-pipe
-rwxr-xr-xruby/named-pipe-a.rb12
-rwxr-xr-xruby/named-pipe-b.rb8
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
+