problems with exec()

This is a discussion on problems with exec() within the PHP General forums, part of the PHP Programming Forums category; hello; I am trying to write a script to do some auto configuration of my webserver. Part of the process ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-30-2006
Ray
 
Posts: n/a
Default problems with exec()

hello;
I am trying to write a script to do some auto configuration of my
webserver. Part of the process involves copying some configuration files
from other places on the server to a working directory where they can be
modified.
I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5
I can't seem to get the exec() command to work.
I have an external shell script called 'copy' that takes care of getting
files. script is currently set to mode 777 when run from the shell it
works perfectly.

however, in the php script

echo exec('whoami');
exec('/path/to/copy');
the only return is
'www' (the username correctly returned from whoami) also files aren't changed.
any suggestions, pointers, log files to check would be appreciated as I
have spent several hours on google, in manuals, etc. haven't tried the
ougi board, but that's about it ;-)
tia
Ray
Reply With Quote
  #2 (permalink)  
Old 11-30-2006
admin@ensifex.nl
 
Posts: n/a
Default Re: [PHP] problems with exec()

Try

exec('/path/to/copy', $return);
print_r($return);

read the manual : http://nl3.php.net/manual/en/function.exec.php

Description
string exec ( string command [, array &output [, int &return_var]] )

gr,
Thijs

On Wed, 29 Nov 2006 23:22:13 -0700, "Ray" <ray@media32.ca> wrote:
> hello;
> I am trying to write a script to do some auto configuration of my
> webserver. Part of the process involves copying some configuration files
> from other places on the server to a working directory where they can be
> modified.
> I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5
> I can't seem to get the exec() command to work.
> I have an external shell script called 'copy' that takes care of getting
> files. script is currently set to mode 777 when run from the shell it
> works perfectly.
>
> however, in the php script
>
> echo exec('whoami');
> exec('/path/to/copy');
> the only return is
> 'www' (the username correctly returned from whoami) also files aren't
> changed.
> any suggestions, pointers, log files to check would be appreciated as I
> have spent several hours on google, in manuals, etc. haven't tried the
> ougi board, but that's about it ;-)
> tia
> Ray
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Reply With Quote
  #3 (permalink)  
Old 11-30-2006
Juanjo Pascual
 
Posts: n/a
Default Re: [PHP] problems with exec()

What is the safe_mode value in your php.ini?

To run exec the value of your safe_mode has to be OFF.


admin@ensifex.nl escribió:
> Try
>
> exec('/path/to/copy', $return);
> print_r($return);
>
> read the manual : http://nl3.php.net/manual/en/function.exec.php
>
> Description
> string exec ( string command [, array &output [, int &return_var]] )
>
> gr,
> Thijs
>
> On Wed, 29 Nov 2006 23:22:13 -0700, "Ray" <ray@media32.ca> wrote:
>
>> hello;
>> I am trying to write a script to do some auto configuration of my
>> webserver. Part of the process involves copying some configuration files
>> from other places on the server to a working directory where they can be
>> modified.
>> I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5
>> I can't seem to get the exec() command to work.
>> I have an external shell script called 'copy' that takes care of getting
>> files. script is currently set to mode 777 when run from the shell it
>> works perfectly.
>>
>> however, in the php script
>>
>> echo exec('whoami');
>> exec('/path/to/copy');
>> the only return is
>> 'www' (the username correctly returned from whoami) also files aren't
>> changed.
>> any suggestions, pointers, log files to check would be appreciated as I
>> have spent several hours on google, in manuals, etc. haven't tried the
>> ougi board, but that's about it ;-)
>> tia
>> Ray
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>

>
>


Reply With Quote
  #4 (permalink)  
Old 11-30-2006
Jan Schröter
 
Posts: n/a
Default Re: [PHP] problems with exec()

Think he's not getting an general error - just didn't read the manual concerning
the return value of exec.

kind regards
jan

Juanjo Pascual wrote:
> What is the safe_mode value in your php.ini?
>
> To run exec the value of your safe_mode has to be OFF.
>
>
> admin@ensifex.nl escribió:
>> Try
>>
>> exec('/path/to/copy', $return);
>> print_r($return);
>>
>> read the manual : http://nl3.php.net/manual/en/function.exec.php
>>
>> Description
>> string exec ( string command [, array &output [, int &return_var]] )
>>
>> gr,
>> Thijs
>>
>> On Wed, 29 Nov 2006 23:22:13 -0700, "Ray" <ray@media32.ca> wrote:
>>
>>> hello;
>>> I am trying to write a script to do some auto configuration of my
>>> webserver. Part of the process involves copying some configuration files
>>> from other places on the server to a working directory where they can be
>>> modified.
>>> I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5
>>> I can't seem to get the exec() command to work.
>>> I have an external shell script called 'copy' that takes care of getting
>>> files. script is currently set to mode 777 when run from the shell it
>>> works perfectly.
>>>
>>> however, in the php script
>>>
>>> echo exec('whoami');
>>> exec('/path/to/copy');
>>> the only return is
>>> 'www' (the username correctly returned from whoami) also files aren't
>>> changed.
>>> any suggestions, pointers, log files to check would be appreciated as I
>>> have spent several hours on google, in manuals, etc. haven't tried the
>>> ougi board, but that's about it ;-)
>>> tia
>>> Ray
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>

>>
>>

>

Reply With Quote
  #5 (permalink)  
Old 11-30-2006
Ray
 
Posts: n/a
Default Re: [PHP] problems with exec()

Hi, thanks for your help.
I was using

exec('/path/to/copy', $return);
var_dump($return);
(but I simplified it for posting)

and I was still getting no output.
actually, the return value is the least of my concerns, I just want this
script to move some files around and the script works from the command line.
as for safe_mode, it's off. Also the whoami in the previous line works as
expected.
Any pointers would be appreciared.
Tia
Ray

-----Original Message-----
From: Jan Schröter <schroeter.jan@web.de>
To: php-general@lists.php.net
Date: Thu, 30 Nov 2006 09:09:49 +0100
Subject: Re: [php] problems with exec()

> Think he's not getting an general error - just didn't read the manual
> concerning
> the return value of exec.
>
> kind regards
> jan
>
> Juanjo Pascual wrote:
> > What is the safe_mode value in your php.ini?
> >
> > To run exec the value of your safe_mode has to be OFF.
> >
> >
> > admin@ensifex.nl escribió:
> >> Try
> >>
> >> exec('/path/to/copy', $return);
> >> print_r($return);
> >>
> >> read the manual : http://nl3.php.net/manual/en/function.exec.php
> >>
> >> Description
> >> string exec ( string command [, array &output [, int &return_var]] )
> >>
> >> gr,
> >> Thijs
> >>
> >> On Wed, 29 Nov 2006 23:22:13 -0700, "Ray" <ray@media32.ca> wrote:
> >>
> >>> hello;
> >>> I am trying to write a script to do some auto configuration of my
> >>> webserver. Part of the process involves copying some configuration

> files
> >>> from other places on the server to a working directory where they

> can be
> >>> modified.
> >>> I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5
> >>> I can't seem to get the exec() command to work.
> >>> I have an external shell script called 'copy' that takes care of

> getting
> >>> files. script is currently set to mode 777 when run from the shell

> it
> >>> works perfectly.
> >>>
> >>> however, in the php script
> >>>
> >>> echo exec('whoami');
> >>> exec('/path/to/copy');
> >>> the only return is
> >>> 'www' (the username correctly returned from whoami) also files

> aren't
> >>> changed.
> >>> any suggestions, pointers, log files to check would be appreciated

> as I
> >>> have spent several hours on google, in manuals, etc. haven't tried

> the
> >>> ougi board, but that's about it ;-)
> >>> tia
> >>> Ray
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>
> >>

> >

>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Reply With Quote
  #6 (permalink)  
Old 11-30-2006
admin@ensifex.nl
 
Posts: n/a
Default Re: [PHP] problems with exec()

Output you will only get if something goes wrong with the copy process.

But then again you say the 'whoami' command runs perfect. So the only things that
comes to my sleepy brain is incorrect paths or permissions.

Tried it here with 5.2 and 4.4.4 and seems to work. Maybe somebody else has
a clue what's going on.


On Thu, 30 Nov 2006 07:40:45 -0700, "Ray" <ray@media32.ca> wrote:
> Hi, thanks for your help.
> I was using
>
> exec('/path/to/copy', $return);
> var_dump($return);
> (but I simplified it for posting)
>
> and I was still getting no output.
> actually, the return value is the least of my concerns, I just want this
> script to move some files around and the script works from the command
> line.
> as for safe_mode, it's off. Also the whoami in the previous line works as
> expected.
> Any pointers would be appreciared.
> Tia
> Ray
>
> -----Original Message-----
> From: Jan Schröter <schroeter.jan@web.de>
> To: php-general@lists.php.net
> Date: Thu, 30 Nov 2006 09:09:49 +0100
> Subject: Re: [php] problems with exec()
>
>> Think he's not getting an general error - just didn't read the manual
>> concerning
>> the return value of exec.
>>
>> kind regards
>> jan
>>
>> Juanjo Pascual wrote:
>> > What is the safe_mode value in your php.ini?
>> >
>> > To run exec the value of your safe_mode has to be OFF.
>> >
>> >
>> > admin@ensifex.nl escribió:
>> >> Try
>> >>
>> >> exec('/path/to/copy', $return);
>> >> print_r($return);
>> >>
>> >> read the manual : http://nl3.php.net/manual/en/function.exec.php
>> >>
>> >> Description
>> >> string exec ( string command [, array &output [, int &return_var]] )
>> >>
>> >> gr,
>> >> Thijs
>> >>
>> >> On Wed, 29 Nov 2006 23:22:13 -0700, "Ray" <ray@media32.ca> wrote:
>> >>
>> >>> hello;
>> >>> I am trying to write a script to do some auto configuration of my
>> >>> webserver. Part of the process involves copying some configuration

>> files
>> >>> from other places on the server to a working directory where they

>> can be
>> >>> modified.
>> >>> I am running freeBSD 6.0, Apache 2.2.3, php 5.1.5
>> >>> I can't seem to get the exec() command to work.
>> >>> I have an external shell script called 'copy' that takes care of

>> getting
>> >>> files. script is currently set to mode 777 when run from the shell

>> it
>> >>> works perfectly.
>> >>>
>> >>> however, in the php script
>> >>>
>> >>> echo exec('whoami');
>> >>> exec('/path/to/copy');
>> >>> the only return is
>> >>> 'www' (the username correctly returned from whoami) also files

>> aren't
>> >>> changed.
>> >>> any suggestions, pointers, log files to check would be appreciated

>> as I
>> >>> have spent several hours on google, in manuals, etc. haven't tried

>> the
>> >>> ougi board, but that's about it ;-)
>> >>> tia
>> >>> Ray
>> >>>
>> >>> --
>> >>> PHP General Mailing List (http://www.php.net/)
>> >>> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>>
>> >>
>> >>
>> >

>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>

>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Reply With Quote
  #7 (permalink)  
Old 12-02-2006
Ray
 
Posts: n/a
Default Re: [PHP] problems with exec() SOLVED

Thanks for the help. :)
I posted to the freeBSD list and was given the answer there. in case
anyone is interested and for the sake of the archive, I needed a path
specified in the shell script. The following URL provides the necessary
info for fixing the script. http://linux.dbw.org/shellscript_howto.html
again thanks.
Ray
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:21 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0