# Ruby executing shell commands

**URL:** <https://www.ruby-forum.com/t/ruby-executing-shell-commands/194646>\
**Category:** Ruby\
**Created:** [September 8, 2010, 2:25pm UTC](https://www.ruby-forum.com/t/ruby-executing-shell-commands/194646 "2010-09-08T14:25:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gsviteri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8797f3/32.png) [@gsviteri](https://www.ruby-forum.com/u/gsviteri)\
**Post date:** [September 8, 2010, 2:25pm UTC](https://www.ruby-forum.com/t/ruby-executing-shell-commands/194646/1 "2010-09-08T14:25:31Z")

</div>

Hi All,

My scenario seems like: 1 host machine and many others virtual machines.  
(exampling: Windows as host and VM Linux Ubuntu).

I’m looking for a Ruby implementation that manipulates the IPTables on  
this virtual machines. I mean the host machine will have a ruby program  
that will interact to these virtual machines.

I’ve figured out many sites I’ve found a library Net-ssh.

When I’ve tried to run an ‘iptables -L’, it shows me ‘no tty present and  
no askpass program specified’. And looking at Net-ssh API examples to  
perform shell interaction, however I can’t run any example…

I’ve tried many other things too, all of them was unsuccessful.

Of course I’m ruby newbie. =)

Could you guys help me please ?? I will really appreciate that =P

Thanks a lot

---

<div class="post-metadata">

**Author:** ![gsviteri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8797f3/32.png) [@gsviteri](https://www.ruby-forum.com/u/gsviteri)\
**Post date:** [September 8, 2010, 7:25pm UTC](https://www.ruby-forum.com/t/ruby-executing-shell-commands/194646/2 "2010-09-08T19:25:27Z")

</div>

On 9/8/2010 6:25 AM, Guilherme Viteri wrote:

> I’ve figured out many sites I’ve found a library Net-ssh.
> 
> Thanks a lot  
> An example program doing what you ask:  
> [http://gist.github.com/570440](http://gist.github.com/570440)

sample run:

Enter host:   
Enter username:   
Enter password:   
iptables v1.4.4: can’t initialize iptables table `filter’: Permission  
denied (you must be root)  
Perhaps iptables or your kernel needs to be upgraded.  
work complete!

Note: for obvious reasons I didn’t login as root, thus the error.

---

<div class="post-metadata">

**Author:** ![gsviteri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/8797f3/32.png) [@gsviteri](https://www.ruby-forum.com/u/gsviteri)\
**Post date:** [September 8, 2010, 10:09pm UTC](https://www.ruby-forum.com/t/ruby-executing-shell-commands/194646/3 "2010-09-08T22:09:45Z")

</div>

> When I’ve tried to run an ‘iptables -L’, it shows me ‘no tty present and  
> no askpass program specified’. And looking at Net-ssh API examples to  
> perform shell interaction, however I can’t run any example…

maybe you need to login as root, or allow your current user to sudo  
without password the iptables -L command.  
-r
