Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "J.O. Aho" Newsgroups: comp.lang.php Subject: Re: problems with exec() Date: Mon, 16 Apr 2012 07:17:53 +0200 Lines: 46 Message-ID: <9v1oc1FvdvU1@mid.individual.net> References: <9-SdnWmoCP7eZBfSnZ2dnUVZ7q6dnZ2d@giganews.com> <9v0fldFforU1@mid.individual.net> <9v0vlnF4m6U2@mid.uni-berlin.de> <9v100mF8g6U1@mid.uni-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net YyXXZfAQtjv2ZpLNXl2fZAkkU1cNHRxPwSy3m+0dewyZ19Yzob Cancel-Lock: sha1:cmWJ+T+YrbjubJl1h/VJ97/eDO8= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120321 Firefox/11.0 SeaMonkey/2.8 In-Reply-To: <9v100mF8g6U1@mid.uni-berlin.de> Xref: csiph.com comp.lang.php:5537 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