FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » problems with exec()
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: problems with exec() [message #177708 is a reply to message #177707] Mon, 16 April 2012 05:17 Go to previous messageGo to previous message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma:
Senior Member
M. Strobel wrote:
> Am 16.04.2012 00:16, schrieb M. Strobel:
>> Am 15.04.2012 19:43, schrieb J.O. Aho:
>>> 7segment wrote:
>>>> Hi.
>>>>
>>>> I have an interesting problem and I cannot figure out what the problem
>>>> might be.
>>>>
>>>> This does not produce any output:
>>>>
>>>> $response = exec('ifconfig');
>>>> echo $response;
>>>>
>>>> Although when I try other commands, I get a response on the screen. So I
>>>> don't get what's so special about ifconfig.
>>>>
>>>> Could anyone help please?
>>>
>>> ifconfig usually residence in /sbin (some GNU/Linux distribution are in the migration
>>> path of moving it to /usr/sbin), this directory is never in a normal users or a
>>> daemon users $PATH, so you need to give the whole path to this binary to be able to
>>> run it.
>>>
>>> By default the file is executional by all users, but someone may have changed
>>> permissions or setup ACL rules with for example SELinux.
>>>
>>
>> I can tell that on opensuse it it not executable by normal users.
>>
>
> Correct is: on suse it is not found on the path. When called with path /sbin/ifconfig
> in a shell it outputs the NIC configuration. When called like that it outputs nothing:
>
> php> $a = exec('/sbin/ifconfig');
> php> echo $a;
> php> var_dump($a);
> string(0) ""

Think the ifconfig makes a bit environment check and wants a shell, use
shell_exec instead and you will see the output.


--

//Aho
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: $this->delimiter in php explode
Next Topic: We Need Speakers For MOSC2012
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Dec 12 10:48:22 GMT 2024

Total time taken to generate the page: 0.04472 seconds