uncutstone
4/28/2006 5:48:00 PM
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