php-cli

Trying to connect using ssh2_auth_pubkey_file()

I am trying to make a php script that runs on the terminal that would connect to a remote server by ssh and retrieve a file. this is my code so far #!/usr/bin/php -q <?php $cwd = dirname(__FILE__).'/'; $filename = 'retrive-this.file'; $host = 'hostip'; $connection = ssh2_connect($host, 22, array('hostkey'=>'ssh-rsa')); $methods = ssh2_...

PHP DOTNET(): Capturing System.Windows.Forms control events to create a usable WIN gui

I made a Windows GUI through PHP's DOTNET class and System.Windows.Forms. But, I'm stuck on handling button clicks, field updates, form open/close events, etc. I cannot get com_event_sink() working with any events whatsoever. I know of no method to get PHP to fake or sink control event "delegates". The best I can do is hackish - cons...

PHP Cli -Helpful Information when developing backend processes

I really just wanted to know a bit more about the PHP Cli with a few more specific questions that I had.. I know that it is much better to use the CLI for more intense background processes than using php on apache, as it helps (save memory?).. however I'm wondering can you run multiple instances of the cli concurrently? IE: having multip...

PHP Reading Large Text Files

I'm reading a flie with essentially upwards of ~500,000 lines separated out by | for the columns which I am parsing and trying to insert into the database through the CLI.. Is there a better way to read it in so I can use it? Currently I'm inserting it as : $fd = fopen ($txtFileName, "r"); while (!feof ($fd)) { $buffer = f...

Printing better formating in command line

I have a php script that i run via command line like php file.php and in that file i have a print statement like print "<br>Saved the url: {$url} to :{$destination}"; I assumed the br would formant it 1 below the other but when i run the script i get this format which is really hard to read <br>Saved the url: http://example.com/a....

pecl not working on php CLI mode (involving mongoDB in Gearman)

For test purposes I have gearman running on localhost. So I run the gearman worker.php file from php command line. When I test this in normal apache mode, mongoDB works just fine, but when it runs from the gearman worker file I get the error "fatal error: class 'Mongo' not found". Now the Mongo class comes from pecl and the mongo.so exte...

problems using Zend_Db when running php as cli script

Hi, I am trying to add some administration scripts to a Zend Framework project, that will end up being run nightly via cron. However I've hit my first problem with the script when trying to use Zend_Db. I am currently doing a very simple SQL call to get some results and just display them using var_dump() however I get the following e...

PHP Script running on the command line died during echo()

I have a script that runs on the command line, called by a crontab. In the last five attempts to run this script, it has died partway through an echo statement - the cron output only shows part of the intended echo output, and nothing after that is executed. This is a long-running script, being run through php-cli, which performs file ma...

Can I use netcat to run PHP CLI w/ arguments?

Hey all, I'm trying to create a debug listener that listens on a port for a data string and forwards it to a php script as an argument. How can I specify that the input to the port should be used as an argument? For example: The remote device send a string with comma separated values value1,value2,value3 and I'd like to run the command...

How to detect client disconnection on PHP socket listener?

Hi all, I've been testing PHP socket listening, and ran into the aforementioned problem. My test listener works otherwise fine, but if a client disconnects without telling the server, the script goes into and infinite loop until a new client connects. The problem seems to be on line $ready = socket_select($read, $write = NULL, $except =...