Forum: IronRuby A few things about system and IO.popen - what's the current status ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Thibaut B. (Guest)
on 2009-03-04 14:08
(Received via mailing list)
Hi,

sorry if it's a know fact - I could not find the info easily. I hope
this
will be useful.

On Windows, system() seems to work partially, is it normal ? The
following
works:

>>> system("echo hello")
hello
=> true

the following doesn't seem to (although svn is in the path):

>>> system("svn")
=> false
>>> system("svn.exe")
=> false

Still on Windows, it seems that IO.popen crashes (I had a quick look at
IoOps.cs to see if it was implemented):

>>> IO.popen("svn.exe") do |io| puts io.read end
:0:in `popen': La référence d'objet n'est pas définie à une instance
d'un
objet. (System::NullReferenceException)
       from :0:in `popen'
       from :0


I ran the same stuff on Mono and got:

IronRuby 1.0.0.0 on Mono 2.4
Copyright (c) Microsoft Corporation. All rights reserved.

>>> system("blah")
IronRuby.Libraries:0:in `ExecuteProcessAndWait': No such file or
directory
(Errno::ENOENT)
from IronRuby.Libraries:0:in `ExecuteCommandInShell'
from :0:in `system'

>>> system("svn")
=> nil
>>> system("svn > svninfo.txt")
=> nil
>>> exit

Finally, running IO.popen on Mono gives the same output as Windows:
IronRuby 1.0.0.0 on Mono 2.4
Copyright (c) Microsoft Corporation. All rights reserved.

>>> IO.popen("svn.exe") { |io| puts io.read }
:0:in `popen': Object reference not set to an instance of an object
(System::NullReferenceException)
from :0:in `popen'


So my question is: what's the current status on system and IO.popen ? Is
it
supposed to work and is it a regression, or is it not fully implemented
?

I may be able to help at some point here (either by providing patches or
testing on Mono + Windows) if it's not your top priority :)

Given that I use Ruby to glue things together quite a lot, that would be
useful to me.

cheers,

-- Thibaut
Tomas M. (Guest)
on 2009-03-04 18:42
(Received via mailing list)
Implementations of both "system" and "popen" are not solid. Any help
here is very much appreciated! Feel free to submit patches and also new
specs for these methods. Let us know if you need some changes in runtime
(IronRuby.dll) since this assembly is not open to contributions just yet
(but we might be able to factor some stuff out to libraries or provide
the necessary functionality needed in core).

BTW, our tag file for Kernel#system contains this suppressions:

fails:Kernel#system can run basic things that exist
fails:Kernel#system returns false when it can't
fails:Kernel#system does not write to stderr when it can't find a
command
fails:Kernel#system uses /bin/sh if freaky shit is in the command
fails:Kernel#system is a private method
fails:Kernel#system expands shell variables when given a single string
argument
fails:Kernel#system does not expand shell variables when given multiples
arguments

Tomas

From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Thibaut
Barrère
Sent: Wednesday, March 04, 2009 3:37 AM
To: ironruby-core
Subject: [Ironruby-core] A few things about system and IO.popen - what's
the current status ?

Hi,

sorry if it's a know fact - I could not find the info easily. I hope
this will be useful.

On Windows, system() seems to work partially, is it normal ? The
following works:

>>> system("echo hello")
hello
=> true

the following doesn't seem to (although svn is in the path):

>>> system("svn")
=> false
>>> system("svn.exe")
=> false

Still on Windows, it seems that IO.popen crashes (I had a quick look at
IoOps.cs to see if it was implemented):

>>> IO.popen("svn.exe") do |io| puts io.read end
:0:in `popen': La référence d'objet n'est pas définie à une instance
d'un objet. (System::NullReferenceException)
       from :0:in `popen'
       from :0

I ran the same stuff on Mono and got:

IronRuby 1.0.0.0 on Mono 2.4
Copyright (c) Microsoft Corporation. All rights reserved.

>>> system("blah")
IronRuby.Libraries:0:in `ExecuteProcessAndWait': No such file or
directory (Errno::ENOENT)
from IronRuby.Libraries:0:in `ExecuteCommandInShell'
from :0:in `system'

>>> system("svn")
=> nil
>>> system("svn > svninfo.txt")
=> nil
>>> exit

Finally, running IO.popen on Mono gives the same output as Windows:

IronRuby 1.0.0.0 on Mono 2.4
Copyright (c) Microsoft Corporation. All rights reserved.

>>> IO.popen("svn.exe") { |io| puts io.read }
:0:in `popen': Object reference not set to an instance of an object
(System::NullReferenceException)
     from :0:in `popen'


So my question is: what's the current status on system and IO.popen ? Is
it supposed to work and is it a regression, or is it not fully
implemented ?

I may be able to help at some point here (either by providing patches or
testing on Mono + Windows) if it's not your top priority :)

Given that I use Ruby to glue things together quite a lot, that would be
useful to me.

cheers,

-- Thibaut
Curt H. (Guest)
on 2009-03-04 19:24
(Received via mailing list)
I don't know how the semantics differ from Ruby's, but someone
interested in doing this could probably adapt the IronPython source
code.  These functions should be in "nt.cs". :)

From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Tomas M.
Sent: Wednesday, March 04, 2009 8:42 AM
To: removed_email_address@domain.invalid
Subject: Re: [Ironruby-core] A few things about system and IO.popen -
what's the current status ?

Implementations of both "system" and "popen" are not solid. Any help
here is very much appreciated! Feel free to submit patches and also new
specs for these methods. Let us know if you need some changes in runtime
(IronRuby.dll) since this assembly is not open to contributions just yet
(but we might be able to factor some stuff out to libraries or provide
the necessary functionality needed in core).

BTW, our tag file for Kernel#system contains this suppressions:

fails:Kernel#system can run basic things that exist
fails:Kernel#system returns false when it can't
fails:Kernel#system does not write to stderr when it can't find a
command
fails:Kernel#system uses /bin/sh if freaky shit is in the command
fails:Kernel#system is a private method
fails:Kernel#system expands shell variables when given a single string
argument
fails:Kernel#system does not expand shell variables when given multiples
arguments

Tomas

From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Thibaut
Barrère
Sent: Wednesday, March 04, 2009 3:37 AM
To: ironruby-core
Subject: [Ironruby-core] A few things about system and IO.popen - what's
the current status ?

Hi,

sorry if it's a know fact - I could not find the info easily. I hope
this will be useful.

On Windows, system() seems to work partially, is it normal ? The
following works:

>>> system("echo hello")
hello
=> true

the following doesn't seem to (although svn is in the path):

>>> system("svn")
=> false
>>> system("svn.exe")
=> false

Still on Windows, it seems that IO.popen crashes (I had a quick look at
IoOps.cs to see if it was implemented):

>>> IO.popen("svn.exe") do |io| puts io.read end
:0:in `popen': La référence d'objet n'est pas définie à une instance
d'un objet. (System::NullReferenceException)
       from :0:in `popen'
       from :0

I ran the same stuff on Mono and got:

IronRuby 1.0.0.0 on Mono 2.4
Copyright (c) Microsoft Corporation. All rights reserved.

>>> system("blah")
IronRuby.Libraries:0:in `ExecuteProcessAndWait': No such file or
directory (Errno::ENOENT)
from IronRuby.Libraries:0:in `ExecuteCommandInShell'
from :0:in `system'

>>> system("svn")
=> nil
>>> system("svn > svninfo.txt")
=> nil
>>> exit

Finally, running IO.popen on Mono gives the same output as Windows:

IronRuby 1.0.0.0 on Mono 2.4
Copyright (c) Microsoft Corporation. All rights reserved.

>>> IO.popen("svn.exe") { |io| puts io.read }
:0:in `popen': Object reference not set to an instance of an object
(System::NullReferenceException)
     from :0:in `popen'


So my question is: what's the current status on system and IO.popen ? Is
it supposed to work and is it a regression, or is it not fully
implemented ?

I may be able to help at some point here (either by providing patches or
testing on Mono + Windows) if it's not your top priority :)

Given that I use Ruby to glue things together quite a lot, that would be
useful to me.

cheers,

-- Thibaut
Thibaut B. (Guest)
on 2009-03-04 23:17
(Received via mailing list)
Hi,

thanks for the pointers. I'll first have to learn how to compile and
launch the specs on my machine.

If I manage to get something useful, I'll report back.

cheers,

-- Thibaut
This topic is locked and can not be replied to.