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 #177714 is a reply to message #177712] Mon, 16 April 2012 12:43 Go to previous message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma:
Senior Member
Am 16.04.2012 13:27, schrieb Kim André Akerø:
> 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):

Very convincing, thank you. I was about to test why ifconfig would need the shell
environment...

/Str.
[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 07:36:30 GMT 2024

Total time taken to generate the page: 0.04031 seconds