diff options
author | Patrick Simianer <p@simianer.de> | 2016-08-18 10:24:56 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2016-08-18 10:24:56 +0200 |
commit | c2ade58bb868e72ba560553b3f72188453c55e7a (patch) | |
tree | e42b882ede08b7ecdce9c6b35a6a4dcdfe2089ab /ruby | |
parent | 43fcaa14840a18a4ab9e6ab9530933a6c60bd604 (diff) |
ruby: named-pipe
Diffstat (limited to 'ruby')
-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 + |