php-cli

Prevent file differences between live and staging websites AND system scripts (PHP)

I'm trying to find a good way to maintain PHP configuration differences between a dev and live environment. I know how to handle differences when scripts are run by Apache (see below), but not when they are run on the command line, e.g. via cron. Background info: What do I mean by "configuration differences"? Like most code shops, we r...

Is there anyway to run PHP script automatically without user interaction?

hi, I want to send mail to user daily. For that I will store the database some records. The PHP Script will send each record daily as mail to the user. These should be done automatically without admin or user interaction. Please give me some help or suggestion ...

How do I find my server's IP address in PHP(CLI)

Aside from the obvious (localhost, 127.0.0.1) does PHP (command line interface!) have a mechanism for discovering the IP of the computer the script is running on? $SERVER[] will not work as this is not a Web app - this is a command line script. TIA ...

Socket Server/Client conflict when running on same system

Okay - I'm beaten. I have a (PHP-CLI) server written using PHP's socket_* functions. I can connect just fine to it using Putty and it works as expected. However my PHP-CLI client does not work properly. It seems like the client is trying to grab the socket from the server (yes the server/client are on the same system). They do se...

How to get the home directory from a PHP CLI script?

From the command line, I can get the home directory like this: ~/ How can I get the home directory inside my PHP CLI script? #!/usr/bin/php <?php echo realpath(~/); ?> ...

Any existing pure PHP "make" tools?

Let me elaborate on the question... I have a custom CMS (built on codeigniter FTW) that includes many different types of modules. Every time we have a new project come through the door, it is a variation and amalgamation of a few of the existing modules. Sometimes a project comes through with requirements that are not satisfied ...

Declare Empty Array, populate and iterate troubles - PHP

I wrote a script to read the Netflix catalog and populate my DB. Everything worked fine as a web script (except for timeouts) so I shifted to calling directly form the console. I noticed a few oddities, like __construct() no longer being called (but that was easily remidied using the class name as a function. Now I can't get my arrays...

How can I debug a PHP CLI script with xdebug?

I haven't quite figured this out. EVERY piece of documentation I've found covers how to use xdebug to debug scripts running in Apache. I need to debug a php CLI script. So, for instance, how do I pass the XDEBUG_SESSION_START variable in to get xdebug to kick on? I'm specifically trying to debug a CakePHP shell. So if anyone has any ad...

Dirty errors with PHP popen()

Hi, I call a file with popen(): $fp = @popen("/usr/bin/openssl ..."); the specific details don't matter, but what happens here is that when I run the command I receive these errors on a Windows CMD: The system cannot find message text for message number 0x3 in the message file for System. I know that the file don't exist on...

what does the -q flag in cron jobs do?

I have a cron job on my host: /ramdisk/bin/php5 -q /home2/sharingi/public_html/scrape/copyV2.php That is just plain not running. The 'support' is telling me that -q is quiet mode and that is why I am not receiving any output emails of any kind... However all my other cron jobs have been and are running with -q and have been sending me...

Command line progress bar in PHP

I am currently trying to add a progress bar to a command line script and I've tried various solutions (including Zend and Console_ProgressBar). The problem they both have in common is that the progress bar doesn't stick at the bottom of the window because during the script, new lines and other information is outputted. Is there any way ...

convert.php does not run in a screen session

I am trying to convert a big forum. At the moment I have to do this via ssh and start convert.php with "php5 -f convert.php -- $OPTIONS". But my internet connection is a bit buggy and so it is often killed. If i start the above working command in a screen session it does not work. Instead php gives me the HTML code of the "convert.php"...

proc_open() path problem

Hi, i'm using linux and php 5.2.12 i have problem with executing proc_open if i use proc_open('php script.php', $descriptorspec, $pipes); it will show me error sh: /php: No such file or directory if i use proc_open('/usr/bin/php script.php', $descriptorspec, $pipes); or proc_open('php script.php', $descriptorspec, $pipes, ...

How to make CLI timers in Windows Server 2003+IIS6+FastCGI+PHP5.3.1 environment?

For the PHP-CLI timer mentioned in the title, I mean the Travian/Ikariam-like background timers that schedule players' actions. I would like to know how to make such timers in mentioned platform (PHP5.3.1, FastCGI, Windows Server 2003, IIS6). Also, on the other hand, if I deploy the program to a Linux server, will it be easier? ...

Best way for PHP5 CLI to formulate Base Directory?

Ok say I have a code base that is contained in a folder /myProgram/ and has various folders such as /myProgram/lib/, /myProgram/docs/ and so on... How, in PHP, can I go about detecting any folders before /myProgram/ and creating a base variable so my includes and require's can be written relative to the base directory /myProgram/ allowi...

Difference Between getcwd() and dirname(__FILE__) ? Which should I use?

In PHP what is the difference between getcwd() dirname(__FILE__) They both return the same result when I echo from CLI echo getcwd()."\n"; echo dirname(__FILE__)."\n"; Returns: /home/user/Desktop/testing/ /home/user/Desktop/testing/ Which is the best one to use? Does it matter? What to the more advanced PHP developers prefer? ...

php-cli: What is the best way to detect the hosting OS?

I have a script which I want to run on windows under Cygwin and on Linux. I have to make distinction between the two running environment for some purposes. What is the best way to do it? ...

Why Does this Loop Return 1 when using && instead of 'and' ???

Riddle me this... in the while($row = mysql_fetch_assoc($result) and $runningOK) loop, if the PHP && operator is used in place of the and the mysql_fetch_assoc fails terrible and returns just the number 1 when running. I've tried mysql_fetch_array() and in place and I still have the 1 problem. It is when, and only when, I replace the && ...

PHP CLI and Task Scheduler problem

I thought I had set up a successful schedule in Windows to run a PHP script. But all I got was an error which slaps only when run through the task scheduler. Here is how I run the task: I created a batch file runCron.bat: start php.exe reportGenerator.php and placed reportGenerator.php in the same folder as of the batch file. When ...

Get current PHP executable from within script?

I want to run a PHP cli program from within PHP cli. On some machines where this will run, both php4 and php5 are installed. If I run the outer program as php5 outer.php I want the inner script to be run with the same php version. In Perl, I would use $^X to get the perl executable. It appears there's no such variable in PHP? Rig...