[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Open4 : undefined method `spawn'

unbewusst.sein

9/3/2008 12:23:00 PM

I'm trying some samples of open4-0.9.6 :

------------------------------------------------------------------------
#! /usr/bin/env ruby

require 'rubygems'
require 'open4'
include Open4

cat = 'ruby -e" ARGF.each{|line| STDOUT << line} "'

stdout, stderr = '', ''
status = spawn cat, 'stdin' => '42', 'stdout' => stdout, 'stderr' =>
stderr
p status
p stdout
p stderr

stdout, stderr = '', ''
status = spawn cat, 0=>'42', 1=>stdout, 2=>stderr
p status
p stdout
p stderr
------------------------------------------------------------------------

I've just added the shebang and "require 'rubygems'" to the original
file.
When running it, i get :
../spawn.rb:10: undefined method `spawn' for main:Object (NoMethodError)

seems strange to me because the method spawn IS defined in the "module
Open4" (lines 241-320)

any idea ?
--
Une Bévue
4 Answers

ara.t.howard

9/3/2008 7:43:00 PM

0


On Sep 3, 2008, at 6:19 AM, Une B=E9vue wrote:

> I'm trying some samples of open4-0.9.6 :
>
> =
------------------------------------------------------------------------
> #! /usr/bin/env ruby
>
> require 'rubygems'
> require 'open4'
> include Open4
>
> cat =3D 'ruby -e" ARGF.each{|line| STDOUT << line} "'
>
> stdout, stderr =3D '', ''
> status =3D spawn cat, 'stdin' =3D> '42', 'stdout' =3D> stdout, =
'stderr' =3D>
> stderr
> p status
> p stdout
> p stderr
>
> stdout, stderr =3D '', ''
> status =3D spawn cat, 0=3D>'42', 1=3D>stdout, 2=3D>stderr
> p status
> p stdout
> p stderr
> =
------------------------------------------------------------------------
>
> I've just added the shebang and "require 'rubygems'" to the original
> file.
> When running it, i get :
> ./spawn.rb:10: undefined method `spawn' for main:Object =20
> (NoMethodError)
>
> seems strange to me because the method spawn IS defined in the "module
> Open4" (lines 241-320)
>
> any idea ?
> --=20
> Une B=E9vue
>


it does seems strange. for me:

cfp:~ > sudo gem install open4
Successfully installed open4-0.9.6
1 gem installed



cfp:~ > ruby -r rubygems -e' require "open4" and include Open4 and =20
spawn "echo 42", :stdout =3D> STDOUT and p Open4.version '
42
"0.9.6"




a @ http://codeforp...
--
we can deny everything, except that we have the possibility of being =20
better. simply reflect on that.
h.h. the 14th dalai lama




Axel Etzold

9/3/2008 8:10:00 PM

0


-------- Original-Nachricht --------
> Datum: Thu, 4 Sep 2008 04:42:56 +0900
> Von: "ara.t.howard" <ara.t.howard@gmail.com>
> An: ruby-talk@ruby-lang.org
> Betreff: Re: Open4 : undefined method `spawn\'

>
> On Sep 3, 2008, at 6:19 AM, Une Bévue wrote:
>
> > I'm trying some samples of open4-0.9.6 :
> >
> > ------------------------------------------------------------------------
> > #! /usr/bin/env ruby
> >
> > require 'rubygems'
> > require 'open4'
> > include Open4
> >
> > cat = 'ruby -e" ARGF.each{|line| STDOUT << line} "'
> >
> > stdout, stderr = '', ''
> > status = spawn cat, 'stdin' => '42', 'stdout' => stdout, 'stderr' =>
> > stderr
> > p status
> > p stdout
> > p stderr
> >
> > stdout, stderr = '', ''
> > status = spawn cat, 0=>'42', 1=>stdout, 2=>stderr
> > p status
> > p stdout
> > p stderr
> > ------------------------------------------------------------------------
> >
> > I've just added the shebang and "require 'rubygems'" to the original
> > file.
> > When running it, i get :
> > ./spawn.rb:10: undefined method `spawn' for main:Object
> > (NoMethodError)
> >
> > seems strange to me because the method spawn IS defined in the "module
> > Open4" (lines 241-320)
> >
> > any idea ?
> > --
> > Une Bévue
> >
>
>
> it does seems strange. for me:
>
> cfp:~ > sudo gem install open4
> Successfully installed open4-0.9.6
> 1 gem installed
>
>
>
> cfp:~ > ruby -r rubygems -e' require "open4" and include Open4 and
> spawn "echo 42", :stdout => STDOUT and p Open4.version '
> 42
> "0.9.6"
>
>
>
>
> a @ http://codeforp...
> --
> we can deny everything, except that we have the possibility of being
> better. simply reflect on that.
> h.h. the 14th dalai lama
>
>
>

Hi ---

what platform are you on ?
I tried the code you posted and it works fine on my Ubuntu box.
That said, I came across some quite mysterious errors on previous installs of various gems, sent some
mails to this and other lists, where the authors said, "I've just tried the software on a fresh
install of Ubuntu, and it works."
Then I freshly installed Ubuntu, and it worked..... never found out what the error was ..
presumably some path issue with ruby installed in multiple ways ...

Just guessing ...

Best regards,

Axel





--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/...

ara.t.howard

9/3/2008 8:23:00 PM

0


On Sep 3, 2008, at 2:10 PM, Axel Etzold wrote:

> Hi ---
>
> what platform are you on ?

osx.


>
> I tried the code you posted and it works fine on my Ubuntu box.
> That said, I came across some quite mysterious errors on previous
> installs of various gems, sent some
> mails to this and other lists, where the authors said, "I've just
> tried the software on a fresh
> install of Ubuntu, and it works."
> Then I freshly installed Ubuntu, and it worked..... never found out
> what the error was ..
> presumably some path issue with ruby installed in multiple ways ...
>
> Just guessing ...
>
> Best regards,
>
> Axel



all the distros, including osx and ubuntu completely hose ruby. that
includes redhat enterprise, etc, etc. i always build ruby from src:

./configure --prefix=/usr/local/ && make && sudo make install

even on windows (using msys) this has been my preferred method of
installing ruby. i too have heard of issues with ubuntu.

sorry i can't be of more help.

cheers.


a @ http://codeforp...
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama




unbewusst.sein

9/9/2008 5:49:00 PM

0

Axel Etzold <AEtzold@gmx.de> wrote:

> what platform are you on ?

MacOS X 10.4.11
ruby 1.8.6 (2007-09-24 patchlevel 111) [powerpc-darwin8.11.0]
MacPorts install (under /opt/local)
--
Une Bévue