You are here:  » Plesk and Automation


Plesk and Automation

Submitted by support on Mon, 2006-05-08 06:31 in

Hi,

I just wanted to start a new thread to focus on the problems that a few users are experiencing trying to automate feed downloading and importing where Plesk is involved in their hosting setup. However, i'm afraid that I don't quite understand the issues; so if those having Plesk related problems could confirm what I think is the situation:

i) You do not have shell (Telnet or SSH access) to your server, and therefore cannot automate Price Tapestry using the advice in this thread: http://www.pricetapestry.com/node/198, or you can login, but are in a chroot jail (where the root of the server is forced to be your home directory and hense you do not have access to the necessary commands)

ii) Therefore, your only option is to automate via a PHP script, and (I guess) setup that PHP script to be called via a CRON job. However, because your PHP script is being executed by an Apache virtual host that was configured by Plesk, it is too locked down (and possibily chroot'ed as well) such that either;

- the exec() function is disabled entirely, ~or~
- exec() works, but cannot access the commands you need such as wget, unzip, gzip etc.

What would help is if someone who is having these problems could run the following test script. It should print out the wget command version information at least once (passthru and exec work in exactly the same way as far as executing the command is concerned)

<?php
  
print "<p>Trying wget</p>";
  
passthru("wget --version");
  print 
"<p>Trying /bin/wget</p>";
  
passthru("/bin/wget --version");
  print 
"<p>Trying /usr/bin/wget</p>";
  
passthru("/usr/bin/wget --version");
?>

However, the chances are that you will see nothing (except the "trying" messages), and if so that is the issue that I think we need to resolve in order for you to create a PHP automation script...

Thanks,
David.

Submitted by ROYW1000 on Mon, 2006-05-08 09:46

David

Here is the result from my plesk:-

Trying wget

Trying /bin/wget

Trying /usr/bin/wget

David if it helps I can set you up a VPS accoutn so you can have a play. Just let me know on theis forum and I will email you the details. I am hosted with Web Fusion Linux VPS.

Roy

Submitted by support on Mon, 2006-05-08 09:57

Thanks Roy,

I'll bear in mind your offer of setting up a test account.

In the mean time; could you confirm the status regarding your Telnet / SSH access to your server? Do you have none at all, or can you login but are very restricted in what you can do?

The other question is; (for you and others with Plesk); is this your own dedicated server that happens to be running Plesk; or do you have a reseller account (or similar) and therefore the server is not dedicated to you; but you can setup unlimited domains etc.?

Another thing that will help is a phpinfo() script. Would it be possible for you to setup a PHP script and post the URL to it (I can then delete the URL if you wish) running the following:

<?php
  phpinfo
();
?>

Thanks,
David.

Submitted by ROYW1000 on Mon, 2006-05-08 11:27

http://www.comparisonbuy.co.uk/phones/phpinfo.php

David I have full control over Telnet and SSH.

It is not a dedicated server and mine is a reseller account with full root access. We are also abale to reboot the server or shut id down etc etc.

Regards

Roy

Submitted by crounauer on Mon, 2006-05-08 11:57

Hi David / Roy,

This is my result from the script.

Trying wget
GNU Wget 1.10.2 (Red Hat modified) Copyright (C) 2005 Free Software Foundation, Inc. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Originally written by Hrvoje Niksic .

Trying /bin/wget

Trying /usr/bin/wget
GNU Wget 1.10.2 (Red Hat modified) Copyright (C) 2005 Free Software Foundation, Inc. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Originally written by Hrvoje Niksic .

Computer Hardware

Submitted by crounauer on Mon, 2006-05-08 11:59

and the URL to phpscript.php is http://lingerie.gynogapod.co.uk/phpinfo.php

Computer Hardware

Submitted by crounauer on Mon, 2006-05-08 12:10

David,

My server is my own box. I do have some customer accounts on the server, but I manage them all.

I have full access to everything.

Simon.

Computer Hardware

Submitted by support on Mon, 2006-05-08 12:12

Thanks guys - it's looking like separate issues then in each case here.

Roy -

First thing to note is that safe mode is enabled in your configuration, with the value of safe_mode_exec_dir being empty, so exec() will not work on anything that is not in the same directory as the script.

Now, if you have clients on your reseller account; you might not want to turn safe mode off. However, if you are happy to disable safe mode, you need to log into your VPS account as root and edit /etc/php.ini. Look for the line containing "safe_mode=on", and change it to "off".

If you do have clients and do not want to turn safe mode off, then I would pursue automation via shell scripts as this will give you a far more robust solution without having to change your PHP configuration:
http://www.pricetapestry.com/node/198

Simon -

There is no safe mode restriction on your server, and the test script seemed to execute the wget command successfully. Can you remind me as to what aspect of PHP based automation is failing on your server as from the look of things it _should_ be working ok...

Thanks,
David.

Submitted by crounauer on Mon, 2006-05-08 12:29

Hi David,

Thanks again for your fanatical support!

The script below , which is at this location http://lingerie.gynogapod.co.uk/feeds/download1.php gives this error

wget program (usr/bin/wget) not found - using PHP method
unzip program for zip (usr/bin/unzip) not found - disabled
unzip program for rar (usr/bin/unrar) not found - disabled
unzip program for gzip (usr/bin/gzip) not found - disabled

<?php
  
// destination directory for downloaded files - must be writable by PHP
  
$targetDir "../feeds/";
  
// path to wget program for retrieval
  
$wgetProgram "/usr/bin/wget";
  
// path to various unzip programs
  
$unzipPrograms["zip"] = "/usr/bin/unzip";
  
$unzipPrograms["rar"] = "/usr/bin/unrar";
  
$unzipPrograms["gzip"] = "/usr/bin/gzip";
  
more coding.....
?>

Computer Hardware

Submitted by crounauer on Mon, 2006-05-08 12:32

David,

I think I will abort trying to get this to work as it has taken up far to much of my time and yours.

Your supprot and help has been excellent - thank you!

I will use the workaround as described at http://www.pricetapestry.com/node/198

Regards,
Simon.

Computer Hardware

Submitted by support on Mon, 2006-05-08 12:35

Hi Simon,

That's strange - the test performed earlier in this thread confirms that your PHP instance has access to wget; yet the test for it in the download script fails.

We know that on your server, wget is /usr/bin/wget, so could you try this test script:

<?php
  
// path to wget program for retrieval
  
$wgetProgram "/usr/bin/wget";
  if (!
file_exists($wgetProgram))
  {
    print 
"<p>wget program ($wgetProgram) not found using file_exists</p>";
  }
  
passthru($wgetProgram." --version");
?>

Will be interesting to see what this produces...

Thanks,
David.

Submitted by crounauer on Mon, 2006-05-08 12:38

Hi David,

Think gremlins have taken over :)

Here are the results for http://lingerie.gynogapod.co.uk/test3.php

wget program (/usr/bin/wget) not found using file_exists
GNU Wget 1.10.2 (Red Hat modified) Copyright (C) 2005 Free Software Foundation, Inc. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Originally written by Hrvoje Niksic .

Computer Hardware

Submitted by support on Mon, 2006-05-08 12:42

A ha...! Now it makes sense:

http://uk.php.net/file_exists

file_exists() is affected by open_basedir, but exec() isn't.

On your server, open_basedir is set to the following:

/home/httpd/vhosts/gynogapod.co.uk/subdomains/lingerie/httpdocs:/tmp

Ergo, it can't find wget when looking with file_exits(), but as your server is not otherwise running in safe mode, there is nothing stopping exec() from running.

I think the download script might work if you just remove all the tests for the files....!

Submitted by crounauer on Tue, 2006-05-09 11:42

Hi David,

You are quite right, it does work even though it is giving the errors. Would the same problem be for the unzipping?

With the TD feed, it downloads but doesn't unzip

Sample Data...
"ÌF¼ÇîÂƝàžÞِ(É7IV˜²==_&@²H¢\$Óñþø“™U€bQn€)Û³³jYR¬Ê¬¼"

Computer Hardware

Submitted by support on Tue, 2006-05-09 11:49

TD feeds are gzipped, so this could indicate that /usr/bin/gzip does not exist on your server.

Can you check for it manually? You will need to login (Telnet or SSH), then run /usr/bin/gzip to see what happens.

If it is not found, or is in a different location (use "locate gzip") you will need to update the path to gzip in the script...

Cheers,
David.