Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: exec() problem

  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts

    exec() problem

    Hi,
    Using exec to run an ImageMagick script after using move_uploaded_file to a temp folder in my directory:

    PHP Code:
    exec(convert /home/twsports/public_html/images/news/tmp/main_football.jpg -resize 150x150  /home/twsports/public_html/images/news/main_football.jpg
    I have chmod the /news/ and /news/tmp/ directories to 777 to allow read/write/execute

    The file is being moved to tmp but the exec function is not working.
    When I ssh the command it works.

    Any ideas?
    Daemonkin.
    If this was helpful, please add to my reputation
    Thousand Sons - Freelance Web Developer - ninetyonedegrees.com

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,048
    Thanks
    10
    Thanked 93 Times in 91 Posts
    try the full path to convert ('which convert' on the command line)
    e.g.
    PHP Code:
    <?
    exec
    ('/usr/bin/convert /home/twsports/public_html/images/news/tmp/main_football.jpg -resize 150x150  /home/twsports/public_html/images/news/main_football.jpg');  
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Firepages: Tried that to no effect.

    Anyone else got a suggestion? I would gladly try anything at this stage. It has been working previously but I must have configured something on the server to conflict with the command.

    D.
    Daemonkin.
    If this was helpful, please add to my reputation
    Thousand Sons - Freelance Web Developer - ninetyonedegrees.com

  • #4
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    Try and check the following

    1- Your server has access to the directory where you are running the exec command. Sometimes Apache is restricted to a specific folder and therefore, it won't execute if Apache doesn't have access to that folder.

    2- Check that your server support the exec function. Some hosts might disable this function altogether for security reasons.

    3- Please check what output is generated when you run the exec command
    exec( "comamnd", $output );
    print_r( $output);

    If your server is running on a windows machine, you might have to alter the privileges under which Apache runs on, in order to grant it access privileges to System commands.

    Otherwise, check the following url which provides an alternative approach to the exec command

    http://drupal.org/node/14002

    Cheers,
    Ess

  • #5
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Problem has been sorted with some server admin help and a reboot.

    I have been using the convert lib of Imagemagick without problem since it was installed on my server. Recently it just stopped working from the script although the ssh manual command worked fine.

    I am keeping an eye on it and using the full path name of the lib file just in case

    D.
    Daemonkin.
    If this was helpful, please add to my reputation
    Thousand Sons - Freelance Web Developer - ninetyonedegrees.com


  •  

    Posting Permissions

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