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

**URL:** <https://www.ruby-forum.com/t/a-few-things-about-system-and-io-popen-whats-the-current-status/161977>\
**Category:** IronRuby\
**Created:** [March 4, 2009, 1:08pm UTC](https://www.ruby-forum.com/t/a-few-things-about-system-and-io-popen-whats-the-current-status/161977 "2009-03-04T13:08:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [March 4, 2009, 1:08pm UTC](https://www.ruby-forum.com/t/a-few-things-about-system-and-io-popen-whats-the-current-status/161977/1 "2009-03-04T13:08:35Z")

</div>

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 © 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 © 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

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [March 4, 2009, 5:42pm UTC](https://www.ruby-forum.com/t/a-few-things-about-system-and-io-popen-whats-the-current-status/161977/2 "2009-03-04T17:42:56Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [March 4, 2009, 6:24pm UTC](https://www.ruby-forum.com/t/a-few-things-about-system-and-io-popen-whats-the-current-status/161977/3 "2009-03-04T18:24:03Z")

</div>

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](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](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

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [March 4, 2009, 10:17pm UTC](https://www.ruby-forum.com/t/a-few-things-about-system-and-io-popen-whats-the-current-status/161977/4 "2009-03-04T22:17:10Z")

</div>

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
