On Thu, 25 Sep 2008, Hugh Sasse wrote:

> On Wed, 24 Sep 2008, Jeff Hodges wrote:
> 
> > Hugh Sasse wrote:
> > > Is IO.popen supposed to be working OK?
> > > 
> > > I'm getting errors with
> > > 
> > > 
> > >   PYTHON = "C:/cygwin/usr/bin/python"
> > >   PYTHON_PROG = "-../AnnaAIML-.7.0/anna_brain/skel.py"
> > >   MODE = "w+"
> > >   PAUSE = 30
> > > 
> > >   def setup_program
> > >     if block_given?
> > >       Open3.popen3(PYTHON_PROG, MODE) do |io|
> > >         sleep PAUSE
> > >         ignore = io.read
> > >         yield io
> > >       end
> > >     else
> > >       @io =  IO.popen(PYTHON_PROG, MODE)   #<----- Errors here
> > >       # ignore = @io.read
> > >     end
> > >   end
> > > 
> > > with either No such file or directory" if the - is at the start, or exec
> > > format error if it points to the python script with a #!python
> > > line.  Yes, I'm trying to use ruby's interpretation of the #! line
> > > to spin off a python program.    So why it is treating this as a
> > > file path spec rather than a command string?  The ri docs talk
> > > about it being a command string.  If I put a path
> > > to the Python in there using #{PYTHON} it can't find the file with a 
> > > space:
> > > "#{PYTHON} ../"...
> > > 
> > > So I've tried:
> > > 
> > >   PYTHON_PROG = "-../AnnaAIML-.7.0/anna_brain/skel.py"
> > >   PYTHON_PROG = "../AnnaAIML-.7.0/anna_brain/skel.py"
> > >   PYTHON_PROG = "#{PYTHON} ../AnnaAIML-.7.0/anna_brain/skel.py"
> > > 
> > > all without success.
> > > 
> > > This is not mission critical for me, I'm just messing about with PyAIML
> > > and Shoes, but I'd like to know why my assumptions about popen and popen3
> > > are bonkers.  I'd use expect.rb
> > > http://www.ruby-doc.org/stdlib/libdoc/pty/rdoc/index.html
> > > but I'm fairly sure that won't work on Windows.
> > > 
> > >         Hugh
> > 
> > It looks like the directory you think you are in is not the directory you
> > actually are in. I'd suggest playing around with checking what __FILE__ is 
> > in
> 
> Oh, right, I'm still thinking of Unix scripts that know where they are
> when you invoke them. This is probably it, though the error messages
> are a bit odd.

OK, I have tried this, and I'm still getting exec format error for the
correct path, which I have checked.  Any idea?
> 
> > this program, etc., as Shoes does tricksy eval things that can trip people 
> > up.

        Thank you,
        Hugh

Reply via email to