sed works properly in SSH, not in PHP
- by David
So, I have the following line that I run in PHP with exec($addPHPtags);
$addPHPtags = "/bin/sed -i '/<BODY BGCOLOR=\"#FFFFFF\">/ a\ <?php \n ?> '" . $instance['file'] . " 2>&1";
I'd expect that command to find the key and append it with a php tag. However, when I run it in PHP, I get the following error if I trap command output:
[0] => /bin/sed: -e expression #1, char 39: unknown command: `?'
However, if I run the same command in SSH, it works completely fine:
/bin/sed -i '/<BODY BGCOLOR=\"#FFFFFF\">/ a\ <?php \n ?>' file.php
I'm out of ideas, I've tried various alternatives but to no avail. Any help ? Thanks.