Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Server-side Scripting

  1. #11
    Join Date
    Jan 2010
    Beans
    7

    Re: Server-side Scripting

    Okay, I have managed to get some way further with this. I am now stuck with this code that is supposed to move files from one directory to another:

    PHP Code:
    <?php
    $output 
    shell_exec("sudo find /media/storage/documents -name '*.doc' -type f -exec mv '{}' /media/storage/backup/ \; 2>&1");
    echo 
    "<pre>$output</pre>";
    ?>
    I am calling this from a button on another page, but I am now getting the following message:


    find: missing argument to `-exec'I am so close to what I am trying to achieve, I can taste it !

    Help greatly appreciated
    Last edited by lisati; March 23rd, 2013 at 11:34 AM. Reason: Add tags for readability

  2. #12
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    8,753
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Server-side Scripting

    Unless you have added the "www-data" to the sudoers list, or you are running Apache as root, which is strongly discouraged, you cannot run a shell command with sudo from a PHP script. The easiest solution is to make sure that the www-data user has appropriate permissions on the directories and files and any destinations.
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  3. #13
    Join Date
    Jan 2010
    Beans
    7

    Re: Server-side Scripting

    I already have the permissions set correctly from the sudoers file.


    I would point out aswell that this is an internal websrver, with no access to/from the outside world.

Page 2 of 2 FirstFirst 12

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
  •