GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   php help please <-click (https://gfy.com/showthread.php?t=530537)

Mr Pheer 10-20-2005 07:15 PM

php help please <-click
 
how do i run a php file from the command line?

I'm trying to add it to cron, but just pasting the path to the file is not working

help please :helpme :helpme :helpme

mrthumbs 10-20-2005 07:16 PM

do it through wget..

so

wget "www.site.com/script.php?var=bla"

woj 10-20-2005 07:17 PM

/usr/bin/php /path/to/the/phpfile.php

vending_machine 10-20-2005 07:17 PM

If you have the php binary installed on your system (try 'which php' ) to see if you have it installed, you can do:

Code:

/path/to/your/php /your/file.php

Mr Pheer 10-20-2005 07:19 PM

thanks guys :)

polle54 10-20-2005 07:20 PM

my cronjobs are setup like this, have no idea if you can use this as an example.

00,15,30,45 * * * * cd /www/virtual/something/www.lalalalala.com/htdocs/jobs; /usr/local/bin/php toplist.php3 >/dev/null

Varius 10-20-2005 07:23 PM

Normally in the php script itself, I just set as the first line:

#!/usr/local/bin/php -q (the -q is for quiet mode, so it doesnt echo the php version and all that)

Of course that should be set to wherever php binary is on your machine.

Then you just need to have the path of that script in your crontab, nothing additional.

Mr Pheer 10-20-2005 07:25 PM

ok, dont have wget on the server and cant do it thru cron with php cause it needs to run on the domain itself because of permissions

any ideas?

Varius 10-20-2005 07:29 PM

Quote:

Originally Posted by MrPheer
ok, dont have wget on the server and cant do it thru cron with php cause it needs to run on the domain itself because of permissions

any ideas?

My post above can't work for you ?

If you don't have permissions to execute the php binary on the system, then accessing it via web seems to be the only way. Two options there are via curl, if its installed, or lynx (again if its installed).

Mr Pheer 10-20-2005 07:37 PM

Quote:

Originally Posted by Varius
My post above can't work for you ?

If you don't have permissions to execute the php binary on the system, then accessing it via web seems to be the only way. Two options there are via curl, if its installed, or lynx (again if its installed).

i guess i'm fucked cause neither is installed. its not a file permission thing, the domain is encoded in the script, and it has to be run on the domain itself, filepath isnt working

ArcherJanvier 10-20-2005 07:44 PM

Sorry, wrong thread

Varius 10-20-2005 07:54 PM

Quote:

Originally Posted by MrPheer
i guess i'm fucked cause neither is installed. its not a file permission thing, the domain is encoded in the script, and it has to be run on the domain itself, filepath isnt working

Ok, I understand now, that (I assume) for security, the script was designed to only run on that specific domain....

Another option you could do is write a php script that you will call from the cron, looking something like this:

PHP Code:

#!/usr/local/bin/php -q

<?PHP
set_time_limit
(0);

fopen('http://www.domain.com/whatever.php','r');
exit;

?>

This assumes of course that the servers has allow_url_fopen enabled, which it normally is by default I believe (so if you get a warning and the fopen fails could be because someone has disabled that).

Mr Pheer 10-20-2005 08:10 PM

Quote:

Originally Posted by Varius
Ok, I understand now, that (I assume) for security, the script was designed to only run on that specific domain....

Another option you could do is write a php script that you will call from the cron, looking something like this:

PHP Code:

#!/usr/local/bin/php -q

<?PHP
set_time_limit
(0);

fopen('http://www.domain.com/whatever.php','r');
exit;

?>

This assumes of course that the servers has allow_url_fopen enabled, which it normally is by default I believe (so if you get a warning and the fopen fails could be because someone has disabled that).


That worked!

thanks man... you rock!! :winkwink:

OzMan 10-20-2005 08:13 PM

Is this related to this by chance? One of the options I suggested should work assuming file permissions are set to 777 or whatever they need to be.

edit: nm you figured it out :upsidedow


All times are GMT -7. The time now is 08:35 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123