From: Tim Pease Date: 2007-08-12T09:38:35+09:00 Subject: Re: pipelining On 8/11/07, Fara Nasr wrote: > Hello everyone > > I urgently some help with this code. I am trying to implement the > following pipeline and i keep getting this error Erro:ENOENT > can anybody please help me to get this code working > The error is most likely coming from the "exec" command in the forked child process. It's telling you that one of your commands does not exist. Can you post the full error message? That might give some more insight and a better answer (this is just my best guess). Blessings, TwP PS In your child, call exit! instead of just plain exit. exit! will prevent the at_exit routines from running and killing file descriptors in the parent. See the documentation on fork for more details. > > #input is the command line > def handleCommandLine(input) > # it splits the pipeline into an array > command = input.split('|').map{|c|word_list(c)} > i = 0 > while i< command.length > commands = command.at(i) > execute(commands) > i +=1 > end > end > > def execute(commands) > rd, wr = IO.pipe > if fork.nil? > # child > rd.close > $stdout.reopen(wr) > wr.close > exec(*commands) > exit > else > # parent > wr.close > $stdin.reopen(rd) > rd.close > end > end > -- > Posted via http://www.ruby-forum.com/. > >