#!/usr/bin/ruby def __separator__ puts "\n-----\n" end JARH = 'Just another Ruby hacker,' __separator__ IO.popen("echo `echo #{JARH}`") do |pipe| print pipe.gets.chomp end __separator__ IO.popen('cat', 'w+') do |pipe| pipe.puts JARH print pipe.gets.chomp end __separator__ open('|cat', 'w+') do |pipe| pipe.print JARH print pipe.gets(',') end __separator__ pipe = IO.popen('cat', 'w+') pipe.print JARH pipe.close_write print pipe.read pipe.close __separator__ print `echo #{JARH}`.chomp __separator__ pid = Process.fork if pid Process.waitpid(pid) else exec("echo `echo #{JARH}` | tr -d '\n'") end __separator__ system("echo `echo #{JARH}` | tr -d '\n'") __separator__ IO.popen('-', 'r') do |io| if io # parent print io.gets.chomp Process.wait else # child exec('echo', JARH) exit! # exec failed end end __separator__ in_r, in_w = IO.pipe out_r, out_w = IO.pipe fork do in_w.close STDIN.reopen(in_r) in_r.close out_r.close STDOUT.reopen(out_w) out_w.close exec('cat') exit! # exec failed end in_r.close out_w.close in_w.print JARH in_w.close print out_r.read Process.wait __separator__