[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

IO.popen("-") not available on win98

uncutstone

4/28/2006 4:39:00 AM

my ruby is ruby 1.8.2 (2004-12-25) [i386-mswin32], OS is windows 98

when i run learn.rb:
IO.popen("-") {|f| $stderr.puts "#{Process.pid} is here, f
is #{f}"}
I got :
learn.rb:1156:in `popen': No such file or directory - -
(Errno::ENOENT)
from learn.rb:1156

Book says that popen("-") is not available on all platforms. So I
think it may not supported by my OS, windows 98.

But I really need this way to fork a process, somebody can give some
advice.

Thanks in advance.

5 Answers

uncutstone

4/28/2006 5:47:00 AM

0

If no way, I must take many troubles for transfering structured
arguments to the child process

greg.kujawa

4/28/2006 5:00:00 PM

0

uncutstone wrote:

> Book says that popen("-") is not available on all platforms. So I
> think it may not supported by my OS, windows 98.

You got it. Forking us typically for the land of *NIX and not Windows.
Maybe try http://raa.ruby-lang.org/project/win3... to see if
that will work for you, although I am suspecting that it might only be
for the NT/2000/XP branch of the Windows family. And not the 9x/ME
branch.

Frankly Ruby is typically implemented more from a *NIX perspective,
although there are many noteworthy projects that port it over to the
Windows platform. For example, Instant Rails, One Click Installer,
win32ole, win32api, and various other Win32 utils on the RAA.

uncutstone

4/28/2006 5:48:00 PM

0

Thanks , I have already take the troubles to transfer arguments from
parent to child process from pipe. It looks like the following:

in parent process:
pipes = []
ftpservertasklists.each {
...........
pipe = IO.popen("ruby.exe ftpsearch.rb -p", "w+")
pipe.puts downloadpath
pipe.puts ftpserver["host"]
pipe.puts ftpserver["port"]
pipe.puts ftpserver["username"]
pipe.puts ftpserver["password"]
pipe.puts ftpservertasklist[1]
pipe.putc ?\C-z # a trick, send endofile in a pipe to terminate #
child process's readlines
pipes << pipe
}
pipes.each { |apipe|
apipe.each { |line|
completetasks << line
}
}

in child process :
ftpserver = Hash.new
localpath = gets.strip
ftpserver["host"] = gets.strip
ftpserver["port"] = gets.strip
ftpserver["username"] = gets.strip
ftpserver["password"] = gets.strip
tasklist = readlines
completetasks = Ftpfileutils.downloadfiles_process(ftpserver, tasklist,
localpath)
puts completetasks

if popen("-") worked, I wouldn't need lots of puts and gets to transfer
arguments from parent to child

greg.kujawa

4/28/2006 5:59:00 PM

0

uncutstone wrote:

> if popen("-") worked, I wouldn't need lots of puts and gets to transfer
> arguments from parent to child

Could you rewrite/refactor things to utilize threads? This might make
things easier to get a handle on depending...

uncutstone

4/29/2006 1:06:00 AM

0

In fact, I had a multi-thread version. But comparing multi-thread
version and multi-process one, the later has better performance.

Considering following quoteed from < programming ruby>:
"Often the simplest way to do two things at once is by using Ruby
threads. These are totally in-process, implemented within the Ruby
interpreter. That makes the Ruby threads completely portable---there is
no reliance on the operating system---but you don't get certain
benefits from having native threads. .... And if some thread happens to
make a call to the operating system that takes a long time to complete,
all threads will hang until the interpreter gets control back "

I think ruby thread isn't as powerful as the native thread. So I
choose to use multi-process to implement my ftp downloader. Comparing
the two version, multi-process version is really faster.