Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5537

Re: problems with exec()

From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: problems with exec()
Date 2012-04-16 07:17 +0200
Message-ID <9v1oc1FvdvU1@mid.individual.net> (permalink)
References <9-SdnWmoCP7eZBfSnZ2dnUVZ7q6dnZ2d@giganews.com> <9v0fldFforU1@mid.individual.net> <9v0vlnF4m6U2@mid.uni-berlin.de> <9v100mF8g6U1@mid.uni-berlin.de>

Show all headers | View raw


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

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

problems with exec() 7segment <7segment@nowhere.com> - 2012-04-15 11:37 -0500
  Re: problems with exec() 7segment <7segment@nowhere.com> - 2012-04-15 11:47 -0500
    Re: problems with exec() Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-15 13:34 -0400
  Re: problems with exec() "J.O. Aho" <user@example.net> - 2012-04-15 19:43 +0200
    Re: problems with exec() "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-16 00:16 +0200
      Re: problems with exec() "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-16 00:22 +0200
        Re: problems with exec() "J.O. Aho" <user@example.net> - 2012-04-16 07:17 +0200
          Re: problems with exec() Une Bévue <unbewusstsein@fai.invalid> - 2012-04-16 10:07 +0200
            Re: problems with exec() "J.O. Aho" <user@example.net> - 2012-04-16 19:29 +0200
              Re: problems with exec() Une Bévue <unbewusstsein@fai.invalid> - 2012-04-18 15:44 +0200
                Re: problems with exec() "J.O. Aho" <user@example.net> - 2012-04-18 18:02 +0200
                Re: problems with exec() Une Bévue <unbewusstsein@fai.invalid> - 2012-04-18 19:43 +0200
                Re: problems with exec() "J.O. Aho" <user@example.net> - 2012-04-18 20:37 +0200
                Re: problems with exec() Une Bévue <unbewusstsein@fai.invalid> - 2012-04-18 23:31 +0200
  Re: problems with exec() Kim André Akerø <kimandre@nospambetadome.com> - 2012-04-16 13:27 +0200
    Re: problems with exec() "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-16 14:43 +0200

csiph-web