Professional Web Applications Themes

[PHP] shell_exec - PHP Development

Rodney Green wrote: > My web server runs as the user 'apache.' (...) > the script successfully from the command line as root but when I run it in > the browser the shell script executes but fails. > (...) > I've set the permissions of the script to be executable for anyone. Shell side: - must be readable and executable by user (apache or perhaps everyone) - suid bit work only for programs, not scripts I think - shell can only execute cmds for which it's effective user has sufficient permissions Try this (as root on webserver), if you ...

  1. #1

    Default Re: [PHP] shell_exec

    Rodney Green wrote:
    > My web server runs as the user 'apache.' (...)
    > the script successfully from the command line as root but when I run it in
    > the browser the shell script executes but fails.
    > (...)
    > I've set the permissions of the script to be executable for anyone.
    Shell side:
    - must be readable and executable by user (apache or perhaps everyone)
    - suid bit work only for programs, not scripts I think
    - shell can only execute cmds for which it's effective user has
    sufficient permissions

    Try this (as root on webserver), if you can login as apache.
    If you can't login as apache, log as a normal user (not root)
    # su - apache
    $ cd /path/to/script
    $ ./myscript.sh
    You will probably see errors here.

    If not, it probably is a safemode restriction. See
    [url]http://www.php.net/manual/en/features.safe-mode.php#ini.safe-mode[/url]
    and set the safe_mode_* variables in php.ini or in a .htaccess,
    in particular safe_mode_exec_dir ...

    Hope it helps

    --
    Christophe Chisogne
    [url]http://www.publicityweb.com[/url]

    Christophe Chisogne Guest

  2. #2

    Default Re: [PHP] shell_exec



    > Shell side:
    > - must be readable and executable by user (apache or perhaps everyone)
    > - suid bit work only for programs, not scripts I think
    > - shell can only execute cmds for which it's effective user has
    > sufficient permissions
    >
    > Try this (as root on webserver), if you can login as apache.
    > If you can't login as apache, log as a normal user (not root)
    > # su - apache
    > $ cd /path/to/script
    > $ ./myscript.sh
    > You will probably see errors here.

    As Juan suggested I checked /var/log/messages. The shell script I'm trying
    to run is a script that restarts our web content filter. In the script it
    removes the pid file so it will be recreated when the application is started
    again. The error I'm getting in the message log is "dansguardian: Error
    creating/opening pid file." Any ideas on what to do?

    Thanks for your help,
    Rod

    Rodney Green 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. calling a java program with shell_exec()
    By Martin Hampl in forum PHP Development
    Replies: 2
    Last Post: September 17th, 09:43 PM
  4. [PHP] shell_exec
    By Curt Zirzow in forum PHP Development
    Replies: 0
    Last Post: August 17th, 10:49 PM
  5. shell script not working with shell_exec
    By Chris Overman in forum PHP Development
    Replies: 2
    Last Post: August 14th, 02:58 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