SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Anyone else have trouble with using exec() on a shared host?

  1. #1
    SitePoint Evangelist
    Join Date
    Nov 2005
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Anyone else have trouble with using exec() on a shared host?

    Hello there.

    I have reseller space using a shared hosting solution from UnitedHosting.co.uk

    I have started to use the ImageMagick command through exec() on one of my clients sites, here is a cut down simplified bit of code that I execute:

    exec("/usr/bin/convert /var/www/html/demo/mysite/images/uploaded/example.jpg -resize 120x120 /var/www/html/demo/mysite/images/uploaded/small_example.jpg");

    I want this code to get a file and then resize with the prefix 'small_' on it.

    Thing I seem to be noticing though, is it will work one minute, but then may not work at all at other times. Do you reckon this could be a problem with the shared hosting? Is there usually queues on running exec() commands on a shared host? Has anyone else had this problem? Does anyone know how I can get round it?

    Any ideas/experiences/views would be much appriciated!
    Little Jim

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,563
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    Hi Jim,
    I am also fluffing about with Imagemagick and so far haven't managed to get exec() to do a darn thing!

    I found that using the backtick operator worked for me.

    so something like:
    Code:
    $image = `identify -verbose IM2`;
    works fine.
    Mike Swiffin - Community Team Leader

    Only a woman can read between the lines of a one word answer.....
    I started out with nothing... and still got most of it left!

  3. #3
    SitePoint Evangelist
    Join Date
    Nov 2005
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello spikeZ, thanks for your reply.

    I don't get what this backtick operator does? What is it meant to do? (A nice simple description would be wicked!)

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,563
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    Right then, the backtick operator attempts to run a shell exec command based on what is inside the ticks.

    So in your script you have
    Code:
    exec("/usr/bin/convert /var/www/html/demo/mysite/images/uploaded/example.jpg -resize 120x120 /var/www/html/demo/mysite/images/uploaded/small_example.jpg");
    wheras with a backtick operator it would be:
    Code:
    `/usr/bin/convert /var/www/html/demo/mysite/images/uploaded/example.jpg -resize 120x120 /var/www/html/demo/mysite/images/uploaded/small_example.jpg`;
    Basically does the same thing as shell_exec and exec by attempting to execute the program or command it is given.
    Mike Swiffin - Community Team Leader

    Only a woman can read between the lines of a one word answer.....
    I started out with nothing... and still got most of it left!

  5. #5
    SitePoint Evangelist
    Join Date
    Nov 2005
    Posts
    496
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, thanks for the explaination.

    I suppose the next question would be, whats the benefits/reasons of using the backtick operator instead of the normal exec?

    Many thanks again for your feedback.

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
  •