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 #177712 is a reply to message #177701] Mon, 16 April 2012 11:27 Go to previous messageGo to previous message
Kim Andr Aker is currently offline  Kim Andr Aker
Messages: 17
Registered: September 2010
Karma:
Junior Member
På Sun, 15 Apr 2012 18:37:23 +0200, skrev 7segment <7segment(at)nowhere(dot)com>:

> 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[0];
>
> 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?

Based on your corrected code in your own reply, which lists the second
line as "echo $response;", I can see what you problem would be.

Even if you're allowed to run this particular command from your PHP
script, the return value of exec() is always the LAST line of the command
output. On my system, the last line of the "ifconfig" command is always
blank, which is what $response in your code example would contain. Try
instead to do it like this (and, preferrably, include the full path of
ifconfig):

exec('/sbin/ifconfig', $response); // $response is an array
echo implode('\n', $response);

--
Kim André Akerø
- kimandre(at)NOSPAMbetadome(dot)com
(remove NOSPAM to contact me directly)
[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 09:37:58 GMT 2024

Total time taken to generate the page: 0.04695 seconds