Paul Jungwirth on 19 Jul 2012 13:59:48 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] php pipe to less broken? |
Amir, How are you running the PHP script? From the command line? I notice test.php has no shebang line. Are you actually saying this?: $ php test.php | less Or is it something else? If something else is running both php & less for you, perhaps it is doing something weird with your environment (what is $PAGER?) or passing strange options to less. You might want to also try this: $ php test.php | od --format=cz (Forgive me if `php foo.php` is not how you run command-line php; I'm not a php guy.) Paul On Thu, Jul 19, 2012 at 1:43 PM, Amir Tahvildaran <amir@mathforum.org> wrote: > Thanks Eric, good idea. > > I tried this on my simplified script (which just prints out 10 numbers). > > Doesn't seem to have any magic chars. > > 0$ > 1$ > 2$ > 3$ > 4$ > 5$ > 6$ > 7$ > 8$ > 9$ > (END) jkjk > > > > $ cat test.php > <?php > > for ($i = 0; $i<10; $i++){ > echo $i . "\n"; > } > > ?> > > -Amir > > > > > On Thu, Jul 19, 2012 at 2:26 PM, Eric at Lucii.org <eric@lucii.org> wrote: >> >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> Amir: >> >> Maybe some control characters could be in the output stream? >> >> Instead of less try piping your output through | cat -vet >> >> This will show the EOL as $ and a carriage return as ^M >> Other control characters in a similar way: (BEL = ^G, etc.) >> >> Hope that helps. >> >> Eric >> >> >> On 07/19/2012 01:46 PM, Amir Tahvildaran wrote: >> > Not sure what's going on here. On a CentOS 6.2 vm when I pipe php >> > output to less I wind up in some weird mode where "j" and "k" don't move up >> > and down, instead they just queue up at this colon prompt. >> > >> > :jkjk >> > >> > If I hit enter after it sort of goes up/down by a line. If I hit gg or >> > G and then enter I get to the top or bottom of the file. Similarly >> > 'q<enter>' get's me out of it. >> > >> > Is anyone familiar with this mode of less? Same thing happens for more. >> > Same thing happens if I throw tee in the middle (and I can less the tee'd >> > file normally afterwards too). >> > >> > It seems to only be for PHP output, if I cat a file to less it works as >> > expected. If I write a bash script it also works as expected. I tried >> > getting php to exit(0) or exit(1). The php script runs and exits as normal >> > (AFAIK) without the pipe. >> > >> > Any thoughts? >> > >> > -Amir >> > >> > $ php -version PHP 5.3.3 (cli) (built: Jul 3 2012 16:40:30) >> > >> > >> > >> > ___________________________________________________________________________ >> > Philadelphia Linux Users Group -- http://www.phillylinux.org >> > Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce >> > General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug >> > >> >> - -- >> # Eric Lucas >> # >> # "Oh, I have slipped the surly bond of earth >> # And danced the skies on laughter-silvered wings... >> # -- John Gillespie Magee Jr >> >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.11 (GNU/Linux) >> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ >> >> iEYEARECAAYFAlAIUVwACgkQ2sGpvXQrZ/71YwCgtNqPFfmeoXHBVnjrsnOrwpyb >> RSYAoI2OW7YjianehoRMd6DKueK0OKZr >> =XdmJ >> -----END PGP SIGNATURE----- >> >> ___________________________________________________________________________ >> Philadelphia Linux Users Group -- >> http://www.phillylinux.org >> Announcements - >> http://lists.phillylinux.org/mailman/listinfo/plug-announce >> General Discussion -- >> http://lists.phillylinux.org/mailman/listinfo/plug >> > > > ___________________________________________________________________________ > Philadelphia Linux Users Group -- http://www.phillylinux.org > Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce > General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug > -- _________________________________ Pulchritudo splendor veritatis. ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug