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

U

uncutstone

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.
 
U

uncutstone

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

gregarican

uncutstone said:
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/win32-process/ 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.
 
U

uncutstone

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
 
G

gregarican

uncutstone said:
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...
 
U

uncutstone

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top