Forum: Ruby on Rails Problem with `arp -a`

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.
Misha M. (Guest)
on 2009-03-03 12:06
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
Jeff S. (Guest)
on 2009-03-03 13:34
(Received via mailing list)
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`
Misha M. (Guest)
on 2009-03-04 15:56
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.
Jeffrey L. Taylor (Guest)
on 2009-03-04 19:05
(Received via mailing list)
Quoting Misha M. <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
This topic is locked and can not be replied to.