Professional Web Applications Themes

shell_exec question - PHP Development

Greetings learned PHP(eople); I`m using a shell_exec to get a list of files from a specified directory. When I run it locally on my machine i works. When I run it on the other machine I get ===== Warning: shell_exec() [function.shell-exec]: Cannot execute using backquotes in Safe Mode in /var/www/html/search.php on line 9 ===== In /etc/php.ini Safe Mode is off....I read some postings in the archives and on the advice given checked that the owner of the script has the relevant permissions on the directory/files trying to be accessed, and they are the same i.e. root Any ideas ? -- ...

  1. #1

    Default shell_exec question

    Greetings learned PHP(eople);

    I`m using a shell_exec to get a list of files from a specified
    directory.

    When I run it locally on my machine i works. When I run it on the other
    machine I get

    =====
    Warning: shell_exec() [function.shell-exec]: Cannot execute using
    backquotes in Safe Mode in /var/www/html/search.php on line 9
    =====

    In /etc/php.ini Safe Mode is off....I read some postings in the archives
    and on the advice given checked that the owner of the script has the
    relevant permissions on the directory/files trying to be accessed, and
    they are the same i.e. root

    Any ideas ?


    --
    Chris Blake
    Support Consultant
    Office : (011) 782-0840
    Fax : (011) 782-0841
    Mobile : 083 985 0379
    Website: http://www.pbpc.co.za

    What does education often do? It makes a straight cut ditch of a
    free meandering brook.
    -- Henry David Thoreau


    13:10:21 up 21 days, 4:40, 3 users, load average: 0.48, 0.33, 0.28
    Chris Guest

  2. #2

    Default Re: [PHP] shell_exec question

    safe mode is on, turn it off and restart webserver. Then you can check
    directory permissions.

    Chris Blake wrote:
     
    Marek Guest

  3. #3

    Default Re: [PHP] shell_exec question

    On 08 Oct 2003 13:25:51 +0200, you wrote:
     

    What Marek said.

    However, is there any reason you're not using readdir()?

    http://uk.php.net/manual/en/function.readdir.php
    David Guest

  4. #4

    Default Re: [PHP] shell_exec question

    On Wed, 2003-10-08 at 13:56, David Otton wrote:
     

    I`ve got a whole bunch of other stuff happening using shell_exec, eg
    file searches etc....

    I changed php.ini entry for safemode=on , restarted Apache, but that
    didn`t help.....opendir() returns the following :

    =========

    Warning: opendir() [function.opendir]: SAFE MODE Restriction in effect.
    The script whose uid is 0 is not allowed to access /home owned by uid 0
    in /var/www/html/backups.php on line 8

    Warning: opendir(/home/chris/PBPCBackup/) [function.opendir]: failed to
    open dir: No such file or directory in /var/www/html/backups.php on line
    8

    =========

    I got this error as well prior to changing the safe mode parameter...

    Still lost, but searching :(


    --
    Chris Blake
    Support Consultant
    Office : (011) 782-0840
    Fax : (011) 782-0841
    Mobile : 083 985 0379
    Website: http://www.pbpc.co.za

    Women want their men to be cops. They want you to punish them and tell
    them what the limits are. The only thing that women hate worse from a
    man
    than being slapped is when you get on your knees and say you're sorry.
    -- Mort Sahl


    14:40:40 up 21 days, 6:10, 3 users, load average: 0.32, 0.14, 0.25
    Chris Guest

  5. #5

    Default Re: [PHP] shell_exec question

    Did you edit the right php.ini? Check out phpinfo() output for
    "Configuration File (php.ini) Path"

    Chris Blake wrote:
     
    >
    >
    > I`ve got a whole bunch of other stuff happening using shell_exec, eg
    > file searches etc....
    >
    > I changed php.ini entry for safemode=on , restarted Apache, but that
    > didn`t help.....opendir() returns the following :
    >
    > =========
    >
    > Warning: opendir() [function.opendir]: SAFE MODE Restriction in effect.
    > The script whose uid is 0 is not allowed to access /home owned by uid 0
    > in /var/www/html/backups.php on line 8
    >
    > Warning: opendir(/home/chris/PBPCBackup/) [function.opendir]: failed to
    > open dir: No such file or directory in /var/www/html/backups.php on line
    > 8
    >
    > =========
    >
    > I got this error as well prior to changing the safe mode parameter...
    >
    > Still lost, but searching :(
    >
    >[/ref]
    Marek Guest

  6. #6

    Default Re: [PHP] shell_exec question

    On Wed, 2003-10-08 at 14:51, Marek Kilimajer wrote: 

    Yep, tried that...it states /etc/php.ini, and lists other location of
    /etc/php/, but that directory doesn`t contain a php.ini file....

    --
    Chris Blake
    Support Consultant
    Office : (011) 782-0840
    Fax : (011) 782-0841
    Mobile : 083 985 0379
    Website: http://www.pbpc.co.za

    Campus sidewalks never exist as the straightest line between two points.
    -- M. M. Johnston

    14:56:07 up 21 days, 6:26, 3 users, load average: 0.48, 0.25, 0.21
    Chris Guest

  7. #7

    Default Re: [PHP] shell_exec question

    I think that ALL files in other location are pd, it does not need to
    be named php.ini

    Chris Blake wrote:
     
    >
    >
    > Yep, tried that...it states /etc/php.ini, and lists other location of
    > /etc/php/, but that directory doesn`t contain a php.ini file....
    >[/ref]
    Marek Guest

  8. #8

    Default Re: [PHP] shell_exec question

    On Wed, 2003-10-08 at 15:02, Marek Kilimajer wrote: 

    I checked in /etc/php/ and it lists the following files :

    23_gid.ini
    26_imap.ini
    27_ldap.ini
    34_mysql.ini and
    41_readline.ini

    All these files contain single entries e.g

    extension =readline.so

    and so on.....

    Is there another file I should look for in /etc ?

    --
    Chris Blake
    Support Consultant
    Office : (011) 782-0840
    Fax : (011) 782-0841
    Mobile : 083 985 0379
    Website: http://www.pbpc.co.za

    A person forgives only when they are in the wrong.


    15:08:37 up 21 days, 6:38, 3 users, load average: 0.33, 0.16, 0.14
    Chris Guest

  9. #9

    Default Re: [PHP] shell_exec question

    Then check your httpd.conf for php_(admin_)?(flag|value)

    Chris Blake wrote:
     
    >
    >
    > I checked in /etc/php/ and it lists the following files :
    >
    > 23_gid.ini
    > 26_imap.ini
    > 27_ldap.ini
    > 34_mysql.ini and
    > 41_readline.ini
    >
    > All these files contain single entries e.g
    >
    > extension =readline.so
    >
    > and so on.....
    >
    > Is there another file I should look for in /etc ?
    >[/ref]
    Marek Guest

  10. #10

    Default Re: [PHP] shell_exec question

    On Wed, 2003-10-08 at 15:23, Marek Kilimajer wrote: 

    I checked it but there is nothing for php whatsoever.

    --
    Chris Blake
    Support Consultant
    Office : (011) 782-0840
    Fax : (011) 782-0841
    Mobile : 083 985 0379
    Website: http://www.pbpc.co.za

    Anybody with money to burn will easily find someone to tend the fire.

    15:35:56 up 21 days, 7:05, 3 users, load average: 0.08, 0.08, 0.14
    Chris Guest

  11. #11

    Default Re: [PHP] shell_exec question

    On Wed, 2003-10-08 at 15:23, Marek Kilimajer wrote: 

    OK, so I`ve tried all the suggestions posted, thanks guys...but then I
    went and deleted the php.ini file in /etc, and still when I use
    phpinfo(); it gives me the usual phpinfo page...

    So where is the info coming from...another php.ini located somewhere
    else on my drive ?

    A search revealed nadda....so I`m out of ideas right now.....

    --
    Chris Blake
    Support Consultant
    Office : (011) 782-0840
    Fax : (011) 782-0841
    Mobile : 083 985 0379
    Website: http://www.pbpc.co.za

    buzzword, n:
    The fly in the ointment of computer literacy.


    16:16:41 up 21 days, 7:46, 3 users, load average: 0.43, 0.20, 0.24
    Chris Guest

  12. #12

    Default Re: [PHP] shell_exec question

    Start here:

    grep -r safe_mode /*

    ;)

    Chris Blake wrote:
     
    >
    >
    > OK, so I`ve tried all the suggestions posted, thanks guys...but then I
    > went and deleted the php.ini file in /etc, and still when I use
    > phpinfo(); it gives me the usual phpinfo page...
    >
    > So where is the info coming from...another php.ini located somewhere
    > else on my drive ?
    >
    > A search revealed nadda....so I`m out of ideas right now.....
    >[/ref]
    Marek Guest

  13. #13

    Default Re: [PHP] shell_exec question

    Chris Blake wrote:
     

    First, make sure to restart Apache after you do anything to php.ini
    Secondly, when php.ini is absent, php starts with default options.
     

    If there are any .htaccess files, they can include php overrides also.
    Check to make sure that "local" and "master" values are what you want
    them to be.

    --
    Burhan Khalid
    phplist[at]meidomus[dot]com
    http://www.meidomus.com
    Burhan Guest

  14. #14

    Default Re: [PHP] shell_exec question

    I thought about it, but safe mode can be set only in php.ini or httpd.conf

    Burhan Khalid wrote:
     
    >
    >
    > First, make sure to restart Apache after you do anything to php.ini
    > Secondly, when php.ini is absent, php starts with default options.

    >
    >
    > If there are any .htaccess files, they can include php overrides also.
    > Check to make sure that "local" and "master" values are what you want
    > them to be.
    >[/ref]
    Marek Guest

  15. #15

    Default Re: [PHP] shell_exec question

    Is there a .htaccess file in (or above) the directory that the script is
    in? If so, look to see if safe mode is turned on there.

    Chris Blake wrote:
     
    >
    >
    > OK, so I`ve tried all the suggestions posted, thanks guys...but then I
    > went and deleted the php.ini file in /etc, and still when I use
    > phpinfo(); it gives me the usual phpinfo page...
    >
    > So where is the info coming from...another php.ini located somewhere
    > else on my drive ?
    >
    > A search revealed nadda....so I`m out of ideas right now.....
    >[/ref]

    --
    By-Tor.com
    It's all about the Rush
    http://www.by-tor.com
    John Guest

Similar Threads

  1. shell_exec sudo problem
    By Paul in forum FreeBSD
    Replies: 2
    Last Post: February 19th, 09:03 PM
  2. Can't get shell_exec() to work!
    By NeoPhreak in forum PHP Development
    Replies: 5
    Last Post: September 25th, 07:18 PM
  3. [PHP] shell_exec
    By Curt Zirzow in forum PHP Development
    Replies: 0
    Last Post: August 17th, 10:49 PM
  4. shell script not working with shell_exec
    By Chris Overman in forum PHP Development
    Replies: 2
    Last Post: August 14th, 02:58 PM
  5. [PHP] shell_exec
    By Christophe Chisogne in forum PHP Development
    Replies: 1
    Last Post: August 6th, 02:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139