Web Hosting Talk







View Full Version : Executing encoded PHP file at command line


Omair @ HB
04-14-2002, 04:49 AM
Hello Guys,

I encoded a PHP file through PHP encoder and want to execute the file at the command line and want a crontab to run it every 1 hour.

But when I do:


[root folder]# ./file.php



I get:


sh: ./file.php: cannot execute binary file


I have'nt chmodded the file or done anything else, just uploaded it in binary mode as well as ASCII mode too but it won't work.




Salam,
-Omair

ToTheMax
04-14-2002, 05:57 AM
Hi,

Maybe i'm wrong but I don't think you can run the encoded file from shell.

This is an article (http://www.phpbuilder.net/columns/darrell20000319.php3) about using php as a shell scripting language.

Omair @ HB
04-14-2002, 06:29 AM
Thanks for the link mate, but I had read that article before only.

Still looking for advice.



TIA



Salam,
-Omair

Thomas.N11
04-14-2002, 08:38 AM
You need the PHP binary to execute scripts from a shell.

Try, 'php file.php' or locate your php binary (most likely /usr/local/bin/php) and reference it directly: '/usr/local/bin/php file.php' (or whatever the path may be)

If you can't find a php executable then you need to compile php without apxs.

Let me know if you need more help.

Omair @ HB
04-14-2002, 03:58 PM
Hey Thomas,

Thanks, that worked. Ok. One more question now.

I want the cron.hourly to execute that file each hour using command:

php myfile.php


I remember that I can do that using a filename.sh script created in cron.hourly folder which would have something like

!#bin/sh

php /home/sites/home/web/myfile.php


Am I right? If yes, then what contents would the script have?



Salam,
-Omair

Jedito
04-14-2002, 06:47 PM
I suggest to use lynx in cronjobs

lynx -dump http://domain.com/file.php

Omair @ HB
04-15-2002, 04:44 AM
So Jorge,

Should I create a .sh file with the contents you mentioned or what?




Salam,
-Omair

Jedito
04-15-2002, 05:05 AM
not really, you can do it

Ex:
0 * * * * lynx -dump http://domain.com/file.php

Omair @ HB
04-15-2002, 07:29 AM
Hello Jedito,

Would using lynx -dump filename.php make sure that php file is executed through the PHP binary?

Actually, I want to execute filename.php every hour or every minute using PHP binary file in /usr/local/bin/php


Salam,
-Omair

ffeingol
04-16-2002, 12:44 PM
You should be able to do it either with a cgi version of php or via lynx. Here are some samples to run it either way, once an hour.


#
#min hour day month dayofw command
#
0 * * * * /path/to/php script.php


or


#
#min hour day month dayofw command
#
0 * * * * /full/path/to/lynx -dump http://domain/path/script.php


You'll have to adjust the min/hour parameters to run it when you want it run.

Frank

p.s. vbul messes up the display a bit so you'll have to match the various coloumns to their headings.

Omair @ HB
04-17-2002, 01:08 PM
Hello Frank,

I am now getting this error when running a Zend Encoded file through Shell Prompt.


[root raqcp]# ./domain2.php

<br>
<b>Fatal error</b>: Corrupted encoded data detected in <b>/home/sites/home/raqcp/domain.php</b> on line <b>1</b><br>


Any idea why? Zend Optimizer is installed!



Salam,
-Omair