Jump to content

Cron Job And Get Problem


spadin

Recommended Posts

Hi,

 

I've been running a cron job from my account for about 2-3 months now with no problems. But as of yesterday without doing anything the cron job sends me an email everytime it tries to run it. I get an email with this error:

 

/bin/sh: line 1: /usr/bin/GET: Permission denied

 

I haven't changed anything, specifically any permissions. The cron job is supposed to run this command:

 

GET http://jpfe:jpfepass@www.digitalpadin.com/jpfe/loadjpfe.php

 

I know it includes a password in there but it doesn't really matter, I am actually going to make this a normal directory eventually.

 

Has Total Choice changed some permission that might not allow me to run a php script as a cron job anymore?

 

Thanks,

Sandro

Link to comment
Share on other sites

Thanks, I submitted a help ticket and I got the answer I was looking for.

 

Here is the response if anyone has the same problem.

 

Due to security reasons we have disabled the get and wget commands on the server. You would need to change the cron to use the format 'php -q /home/(account_username)/public_html/jpfe/loadjpfe.php' to run the script. The password protection should not matter in this case as the file is being run from your account on the server.

.

Thank you for choosing Total Choice Hosting where choice does matter!

 

Rick

 

Technical Support Services Manager

Total Choice Hosting

Link to comment
Share on other sites

Thanks, I submitted a help ticket and I got the answer I was looking for.

 

Here is the response if anyone has the same problem.

 

Just what I didn't need to see... php -q doesn't work or doesn't appear to work when I have to append command line parameters onto the script.

 

For instance black nova traders, an online game has a scheduler system that runs via get. you have to append ?swordfish="password" onto the end of the php script, which never worked right unless called via a URL.

 

I forsee much grief for me.

Link to comment
Share on other sites

Welcome to the forums, cryptoknight! :thumbup1:

 

I downloaded BlackNova Traders and looked at the scheduler.php script that's supposed to be run from a cron job. The code is basically written with the assumption that it will always be called through a web server. Cron jobs don't call PHP scripts through a web server, which is why you have to use the GET command - GET calls the script through the web server just like your browser does.

 

If you're willing to add a little code to the scheduler.php script, I believe you can successfully run it in a cron job without having to use GET.

 

In scheduler.php, insert the following code at line 48 (right after the long block of comments and just before the first line of actual PHP code):

># Code to set PHP variables from command line arguments
# Runs only if not being called through web server
if (!isset($_SERVER['SERVER_PORT'])) {
   # Change to script directory, just like web server does
   chdir(dirname($_SERVER['argv'][0]));
   # Set $PHP_SELF from $_SERVER array value (just in case it's not)
   $PHP_SELF = $_SERVER['PHP_SELF'];
   # Iterate through passed args and set PHP variable for each one
   if ($_SERVER['argc'] > 0) {
       for ($i=1; $i < $_SERVER['argc']; $i++) {
           parse_str($_SERVER['argv'][$i]);
       }
   }
}

Then in your cron job, use the following as the "Command to run":

>php -q /path/to/scheduler.php swordfish=password > /dev/null

When run from a cron job, the above code will see the 'swordfish=password' on the command line and set the PHP variable $swordfish = 'password', which is what scheduler.php is expecting to see. This is what PHP does with the '?swordfish=password' part of the link when you call up scheduler.php in a web browser.

 

You could also place this code in a separate file (with opening <?php and closing ?> PHP tags around the code), then just add an include() statement at line 48 in scheduler.php.

 

Hope this helps...

Link to comment
Share on other sites

I downloaded BlackNova Traders and looked at the scheduler.php script that's supposed to be run from a cron job.  The code is basically written with the assumption that it will always be called through a web server.  Cron jobs don't call PHP scripts through a web server, which is why you have to use the GET command - GET calls the script through the web server just like your browser does.

 

If you're willing to add a little code to the scheduler.php script, I believe you can successfully run it in a cron job without having to use GET.

 

Hope this helps...

 

Thank you so much David. Making mods to files is nothing new for me... Working with php in a non-webserver like environment (i.e. not using get) is though. Thank you for your help. The mod works via phpshell, so I expect that it will work fine via cron.

 

Probably would have felt less griefed if in the process of denying my access to get/wget and lynx, somebody had notified me of the change prior to its being enacted.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...