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


Groups > comp.lang.php > #5543

Re: problems with exec()

From "M. Strobel" <sorry_no_mail_here@nowhere.dee>
Newsgroups comp.lang.php
Subject Re: problems with exec()
Date 2012-04-16 14:43 +0200
Message-ID <9v2if4Fu3uU1@mid.uni-berlin.de> (permalink)
References <9-SdnWmoCP7eZBfSnZ2dnUVZ7q6dnZ2d@giganews.com> <op.wcuvfemmptrp3x@neonk2.intrahouse.local>

Show all headers | View raw


Am 16.04.2012 13:27, schrieb Kim André Akerø:
> På Sun, 15 Apr 2012 18:37:23 +0200, skrev 7segment <7segment@nowhere.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.

Back to comp.lang.php | Previous | Next — Previous 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