Thanks so much for developing this. I can put it to good use right now.
I’ve done some experimenting with your code.
I’m using ruby 1.66, so, some of what I’ve found may be due to that.
When using win32_popen3 to pipe a ruby script you must use the command
(“ruby.exe scriptname”) in order for both fin and fout to work properly.
If you use the command(“scriptname”) the child script will run but fin
doesn’t work properly. You get the following error in the child script
Bad file descriptor (Errno::EBADF)
When using Marshal to pipe an object to a script the following doesn’t
work (Marshal barks at it)
Marshal.dump(some_object, fin)
However, you can overcome this by
data=Marshal.dump(some_object)
fin.print data
on the client side you can retrieve the object
some_obj=Marshal.load($stdin)
It may be made with other version but not verified.
[Install binary]
ruby install.rb
[Install from source]
ruby extconf.rb
nmake
ruby install.rb
[methods]
IO#win32_popen2(cmd[, mode])
Executes cmd as a sub-process. Returns the file objects (child_stdin,
child_stdout).
IO#win32_popen3(cmd[, mode])
Executes cmd as a sub-process. Returns the file objects (child_stdin,
child_stdout, child_stderr).
IO#win32_popen4(cmd[, mode]])
Executes cmd as a sub-process. Returns the file objects (child_stdin,
child_stdout_and_stderr).
Regards.
Park Heesob
–
“Or perhaps the truth is less interesting than the facts?”
Amy Weiss (accusing theregister.co.uk of engaging in ‘tabloid journalism’)
Senior VP, Communications
Recording Industry Association of America
However, you can overcome this by
data=Marshal.dump(some_object)
fin.print data
on the client side you can retrieve the object
some_obj=Marshal.load($stdin)
Just curious … what client side ?
Are you trying some kind of distributed ruby ?
If yes, have you looked at drb on RAA ?
Would be interested in looking at your code.
Thanks,
Sorry for the late reply. I am catching up on missed emails.
The date format is incorrect. Asking for MM-dd-yy, it was sent yyyy-mm-dd.
I think you should just change the test:
fin.print “2002-01-01\n” to fin.print “01-01-02\n”
I prefer “01-13-02\n”, since it avoids the mm/dd confusion.
-matt
···
-----Original Message-----
From: Shashank Date [mailto:sdate@kc.rr.com]
Sent: Tuesday, December 31, 2002 8:24 PM
To: ruby-talk ML
Subject: Re: [ANN] win32_popen 0.1
Park,
Thanks a lot for this package.
Unfortunately, when I compile it on my Windows XP Pro using VC++ 6.0 and run
it with
ruby 1.7.3 (2002-11-17) [i386-mswin32] it hangs after doing this:
C:\test>ruby test.rb
test1
The current date is: Tue 12/31/2002
Enter the new date: (mm-dd-yy) 2002-01-01
The system cannot accept the date entered.
Please help.
Thanks and have a Very Happy New Year !
I called the child process the client side (my mistake). Its the process
started with win32_popen. Nothing special about it. I just wanted to see
if I could load an object using it.
I’m running windows XP pro and Ruby 1.66.
I use drb in some of my applications. What’s nice about this code is that
you can start a process feed it some data and then terminate the calling
program without having to wait for the piped process to complete. For
example, a cgi program that sends an email to the client. With threads or
in the cgi code itself, the call to the mail server takes some time to
complete. With popen, you can start a process to send the email. Finish
writing the cgi output then exit the cgi program. The user gets the html
response faster. You could use a drb object to do the same, but any method
call on that object would have to complete before exiting the cgi program.
Spawning a thread also requires waiting.
However, you can overcome this by
data=Marshal.dump(some_object)
fin.print data
on the client side you can retrieve the object
some_obj=Marshal.load($stdin)
Just curious … what client side ?
Are you trying some kind of distributed ruby ?
If yes, have you looked at drb on RAA ?
Would be interested in looking at your code.
Thanks,
Surely YYYY-MM-DD is the only intelligent date format. No confusion
whatsoever. Since the Y2K fiasco, I’ve never seen any advantage in
abbreviating the year, even in informal writing.
Gavin
···
On Thursday, January 23, 2003, 6:08:42 AM, Matt wrote:
Sorry for the late reply. I am catching up on missed emails.
The date format is incorrect. Asking for MM-dd-yy, it was sent yyyy-mm-dd.
I think you should just change the test:
fin.print “2002-01-01\n” to fin.print “01-01-02\n”
I prefer “01-13-02\n”, since it avoids the mm/dd confusion.
Surely YYYY-MM-DD is the only intelligent date format. No confusion
whatsoever. Since the Y2K fiasco, I’ve never seen any advantage in
abbreviating the year, even in informal writing.
Agreed, I always use YYYY-MM-DD now and will always write the year out
as YYYY on both formal & informal documents.
I’m working on the principle that if enough of us do it there won’t be a
problem again in 97 years.