I’m trying to communicate with a program (gnucap) using ruby.
The versions of ruby (1.8.1) and gnucap (0.34) are the same on windows
and linux.
When I start gnucap, this is the output:
Gnucap 0.34
The Gnu Circuit Analysis Package
Never trust any version less than 1.0
Copyright 1982-2002, Albert Davis
Gnucap comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome
to redistribute it under certain conditions
according to the GNU General Public License.
See the file “COPYING” for details.
In Linux this program works and shows me “ok”. But on windows the
program stops reading after the last newline: “…details.”
This means the program never reach ok.
It keeps waiting for input.
the output from gnucap on window must be line buffered - because it hasn’t
sent a newline the last line with 'gnucap> ’ on it has not been flushed and is
not available for reading. i bet that, if you ran a few hundred times, you’d
see this behaviour with linux too. i dont know if
gnucap.sync = true
will work
if not perhaps you could write alittle wrapper like this
file: wgnucap.rb
···
On Fri, 14 May 2004, Roeland Moors wrote:
I’m trying to communicate with a program (gnucap) using ruby.
The versions of ruby (1.8.1) and gnucap (0.34) are the same on windows
and linux.
When I start gnucap, this is the output:
Gnucap 0.34
The Gnu Circuit Analysis Package
Never trust any version less than 1.0
Copyright 1982-2002, Albert Davis
Gnucap comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome
to redistribute it under certain conditions
according to the GNU General Public License.
See the file “COPYING” for details.
In Linux this program works and shows me “ok”. But on windows the
program stops reading after the last newline: “…details.”
This means the program never reach ok.
It keeps waiting for input.
I’m trying to communicate with a program (gnucap) using ruby.
The versions of ruby (1.8.1) and gnucap (0.34) are the same on windows
and linux.
When I start gnucap, this is the output:
Gnucap 0.34
The Gnu Circuit Analysis Package
Never trust any version less than 1.0
Copyright 1982-2002, Albert Davis
Gnucap comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome
to redistribute it under certain conditions
according to the GNU General Public License.
See the file “COPYING” for details.
In Linux this program works and shows me “ok”. But on windows the
program stops reading after the last newline: “…details.”
This means the program never reach ok.
It keeps waiting for input.
Any ideas or suggestions?
Thanks
the output from gnucap on window must be line buffered - because it hasn’t
sent a newline the last line with 'gnucap> ’ on it has not been flushed and is
not available for reading. i bet that, if you ran a few hundred times, you’d
see this behaviour with linux too. i dont know if
gnucap.sync = true
will work
if not perhaps you could write alittle wrapper like this
gnucap.sync doesn’t work. (I didn’t try the wrapper yet)
But maybe there is a different solution to this problem.
Is het possible to detect the last line on the output?
(I don’t know the contents of the last line.)
I’m trying to communicate with a program (gnucap) using ruby.
The versions of ruby (1.8.1) and gnucap (0.34) are the same on windows
and linux.
When I start gnucap, this is the output:
Gnucap 0.34
The Gnu Circuit Analysis Package
Never trust any version less than 1.0
Copyright 1982-2002, Albert Davis
Gnucap comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome
to redistribute it under certain conditions
according to the GNU General Public License.
See the file “COPYING” for details.
In Linux this program works and shows me “ok”. But on windows the
program stops reading after the last newline: “…details.”
This means the program never reach ok.
It keeps waiting for input.
Any ideas or suggestions?
Thanks
the output from gnucap on window must be line buffered - because it hasn’t
sent a newline the last line with 'gnucap> ’ on it has not been flushed and is
not available for reading. i bet that, if you ran a few hundred times, you’d
see this behaviour with linux too. i dont know if
gnucap.sync = true
will work
if not perhaps you could write alittle wrapper like this
this, essentially, how my session library works. when i send a command i
create a spcial string that looks something like
BEGIN__CMD_42 END__CMD_42
and ask the interpreter (for example sh) to echo the begining string, run the
command, and then echo the end one. that way i’m guaranteed that the output
stream will look like
(junk)BEGIN__CMD_42\n(output from command)END__CMD_42\n(junk)
it’s then pretty straight forward to parse the output out. you may want to
look at my session package - if you pulled out the popen3 and replaced with
popen i can’t think of any reason it couldn’t be made to work on windows.
-a
···
On Sun, 16 May 2004, Roeland Moors wrote:
The wrapper didn’t work, but I found a solution I just send an extra empty
command after each command.
–
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: Solar-Terrestrial Physics Data | NCEI
TRY :: for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done
===============================================================================