Posts Tagged ‘buffer’

Buffers keep a small amount of information temporarily while waiting for some other process. The most common usage is when data is being communicated over a network – some data is placed into a buffer of a pre-determined size, and this “packet” is sent. On the receiving end the data is stored in another buffer until the full packet arrives. Data is also stored in a hard drive buffer before being read or written, so the entire packet can be loaded at once.

PHP & Perl: How do I redirect all output from STDOUT or STDERR into a file?

The power of PHP often goes without question, however once in a while we remember a little something from Perl that we just wish was as easy in PHP. The truth is, so much is easier with PHP than with Perl that PHP is just awesome, but hey – it’s a programming language – it’s going to have shortcomings. The most common reason we are asked this is for crons – scheduled programs, batches, and such. Often a programmer will want to redirect the output to a certain file, or to /dev/null. In Perl, you are able to do this easy-as-cheese:

open (STDOUT, ">/path/to/file") or die "Can't redirect STDOUT: $!";

open (STDERR, ">>/path/to/file") or die "Can't redirect STDERR: $!";

Please take note: PERL redirects a filehandle in one line!

However, PHP is a bit of a different story: (more…)