# Problem with \`arp -a\`

**URL:** <https://www.ruby-forum.com/t/problem-with-arp-a/161877>\
**Category:** Rails\
**Created:** [March 3, 2009, 11:06am UTC](https://www.ruby-forum.com/t/problem-with-arp-a/161877 "2009-03-03T11:06:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![misha\_mistral](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a183cd/32.png) [@misha\_mistral](https://www.ruby-forum.com/u/misha_mistral)\
**Post date:** [March 3, 2009, 11:06am UTC](https://www.ruby-forum.com/t/problem-with-arp-a/161877/1 "2009-03-03T11:06:55Z")

</div>

Hi everyone.

I have a problem with this command:

@arp\_table = `arp -n`

When I execute it on console, all is perfect, but when I put it in the  
script on Rails the string arp\_table is empty and I don’t view any  
result.

If I do a script like that:

@list = `ls -l`

all works perfectly.

Where is the mistake ?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![misha\_mistral](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a183cd/32.png) [@misha\_mistral](https://www.ruby-forum.com/u/misha_mistral)\
**Post date:** [March 3, 2009, 12:34pm UTC](https://www.ruby-forum.com/t/problem-with-arp-a/161877/2 "2009-03-03T12:34:59Z")

</div>

Misha M. wrote:

> Hi everyone.
> 
> I have a problem with this command:
> 
> @arp\_table = `arp -n`
> 
> When I execute it on console, all is perfect,  
> Are you passing arp any other arguments? On OS X, arp -n just prints a  
> help message to stderr.

> Where is the mistake ?

If arp -n may be printing to stderr, rather than stdout. Try:

@arp\_table = `arp -n 2>&1`

---

<div class="post-metadata">

**Author:** ![misha\_mistral](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a183cd/32.png) [@misha\_mistral](https://www.ruby-forum.com/u/misha_mistral)\
**Post date:** [March 4, 2009, 2:56pm UTC](https://www.ruby-forum.com/t/problem-with-arp-a/161877/3 "2009-03-04T14:56:32Z")

</div>

Jeff S. wrote:

> Misha M. wrote:
> 
> > Hi everyone.
> > 
> > I have a problem with this command:
> > 
> > @arp\_table = `arp -n`
> > 
> > When I execute it on console, all is perfect,  
> > Are you passing arp any other arguments? On OS X, arp -n just prints a  
> > help message to stderr.
> 
> > Where is the mistake ?
> 
> If arp -n may be printing to stderr, rather than stdout. Try:
> 
> @arp\_table = `arp -n 2>&1`

Thank you for your reply.  
The problem was very silly. The user that execute the rails script is  
www-data, and the arp command isn’t in the user’s PATH variable. There  
was, also, a permission problem. I’ve installed sudo and I’ve solved.

---

<div class="post-metadata">

**Author:** ![misha\_mistral](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a183cd/32.png) [@misha\_mistral](https://www.ruby-forum.com/u/misha_mistral)\
**Post date:** [March 4, 2009, 6:05pm UTC](https://www.ruby-forum.com/t/problem-with-arp-a/161877/4 "2009-03-04T18:05:50Z")

</div>

Quoting Misha M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 

What user is the command running as? On my system (OpenSuSE 10.3) arp  
is in  
/sbin, i.e., root only.

Jeffrey
