Piping PHP output to the linux 'less' command causes 'less' to really act up. (CentOS 6.2, didn't happen with CentOS 5.)
When I pipe output from php into 'less', it requires the enter key be pressed after every command, even after the 'j' command (the command to scroll down one line). In addition, the command key is showing up on-screen, and 'less' isn't cleaning up the screen.
So, after running:
$ php -r 'for ($i=0; $i<300; $i++) { print "$i\n";}' | less
and then typing j (which usually scrolls down one line), I see a 'j' character showing up at the bottom of the screen after the ':' character. Pressing enter causes less to finally "take" the j command, and it does indeed scroll, but now I see the ":j" between two adjacent lines of the output:
10
:j
11
When using less with the equivalent output from python, everything is fine and less acts normally:
$ python -c 'for i in xrange(1, 300): print i' | less
What's going on and how do I fix it?
More info:
$ less --version
less 436
Copyright (C) 1984-2009 Mark Nudelman
less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less
$ php --version
PHP 5.3.27 (cli) (built: Aug 26 2013 11:46:37)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
I'm using Terminal.app on Mac OS X to ssh to the box, then running the php command.