views:

109

answers:

3

Hello!

I have a really puzzling problem: I am writing a PHP CLI application running on a debian server. I am connected to the server via SSH, just the normal way. Everything runs as usual. Except the following:

echo "My CLI fun\n\n";
echo "Is this.";

Outputs on the SSH terminal, when executing the PHP script:

My CLI funIs this.

I am really puzzled as I have never had such a problem. The bash behaves normal in all other aspects. I already tried to output chr(10) and such, same problem.

Does anybody have a clue?

A: 

Have you tried using PHP's OS-sensitive constant:

echo "My CLI fun".PHP_EOL.PHP_EOL; 
echo "Is this."; 
Mark Baker
Tried that, did not work either. Another side note: if I echo "ABC ABC", the spaces get stripped to a single space. I start wondering whether some strange output filter postprocesses the scripts output...?
Steffen Müller
A: 

Have you tried...

echo "My CLI fun" . chr(13) . chr(10);
echo "Is this";

..?

I know it's kind of a MSWindows thing, but it works on Ubuntu.

Hermet
Thanks. The thing is resolved now - it was a bash script problem. Sorry for wasting your effort...
Steffen Müller
A: 

Solved. Sorry for wasting your time. The problem was that the php script was passed through a bash script that called it.

So, for people with the same problem: bash scripts seem to filter the output in some strange ways! Try calling the php script directly.

Steffen Müller
Just accept this answer instead of editing "Solved" into the title.
Bill the Lizard
I can accept my own answer only after waiting 2 days. In the mean time, "[SOLVED]" might be a good idea.
Steffen Müller