Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > pipelining

Reply
Thread Tools

pipelining

 
 
Fara Nasr
Guest
Posts: n/a
 
      08-11-2007
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


#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/.

 
Reply With Quote
 
 
 
 
Tim Pease
Guest
Posts: n/a
 
      08-12-2007
On 8/11/07, Fara Nasr <(E-Mail Removed)> 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/.
>
>


 
Reply With Quote
 
 
 
 
Fara Nasr
Guest
Posts: n/a
 
      08-12-2007
Hi Tim,

All right, To illustrate what happens i have add a puts command to the
code ! the result is so bizzare!!!
Here is the code again:


def handleCommandLine(input)
#splits the command line
command = input.split('|').map{|c|word_list(c)}
i = 0
while i< command.length
commands = command.at(i)
puts commands , "...........\n"
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
Process.wait
end
end



so i used this to test it

001>ls | grep D



here is the result!! the correct result must be 001>Desktop and it has
to stop there!!!




ls
...........
grep
D
...........
001>Desktop
...........
Test.rb:45:in `exec': No such file or directory - Desktop
(Errno::ENOENT)
from Test.rb:45:in `execute'
from Test.rb:32:in `handleCommandLine'
from Test.rb:20:in `run'
from Test.rb:17:in `loop'
from Test.rb:17:in `run'
from Test.rb:68


thanks a lot

Fara
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
enable pipelining on Firefox D Cheung Firefox 1 02-07-2005 12:42 PM
Pipelining tutorial wanted Andrea Campi VHDL 9 11-19-2004 05:04 AM
pipelining tulip VHDL 0 11-05-2004 05:35 AM
How to purposely make pipelining in Handel-C? Peggy VHDL 0 09-08-2004 01:15 AM
Pipelining in VHDL koko VHDL 2 04-29-2004 06:51 PM



Advertisments