title: Convert bash line breaks to HTML line breaks; runs good in BASH, but not through shell_exec
body: <p>I've created a web page that converts bash line breaks [\n] to HTML line breaks [&lt; br />]. This works by having the web page call </p>
  
  <pre><code>shell_exec("bash /xxx/xxx/script.sh");
  </code></pre>
  
  <p>Inside the bash script.sh, it runs a series of SQL queries to replace the bash line breaks with html line breaks, allowing me to format the SQL data into an HTML based email.</p>
  
  <pre><code>`mysql -uXXX -pXXX -e "UPDATE tbl SET var = REPLACE(var, '\n', '&lt;br /&gt;')" db`
  </code></pre>
  
  <p>When I run this bash script via Linux cli, it runs perfect, and the email it sends out uses HTML line breaks. But when I run the script via shell_exec, it just shows in plain text, the bash line break code [\n].</p>
  
  <p>Here is a sample of the email output when running the bash script with PHP shell_exec.</p>
  
  <pre><code>[ var1 ]
  test test test\ntest test test\n test some more
  [ var2 ]
  test test\ntest\ntest
  </code></pre>
  
  <p>And a sample when I run the bash script from linux.</p>
  
  <pre><code>[ var1 ]
  test test test
  test test test
  test some more
  [ var2 ]
  test test
  test
  test
  </code></pre>
  
  <p>I know my other SQL queries work such as SELECT MAX(id) [grabbing the appropriate row and data fields]. Any idea as to why the same script runs perfectly fine under linux bash (to run SQL query, replacing line breaks), but not by calling it with PHP shell_exec? Am I missing something here?</p>
  
  <p><em>*</em> httpd error log states:
     sudo: sorry, you must have a tty to run sudo</p>
  
  <p>and when I enable:
      sudo: no tty present and no askpass program specified</p>
  
  <p>Could this be a TTY issue since it's a command/script being called by user apache? If so, any work arounds?</p>