title: shell errors running php exec
body: <p>I have a PHP script that executes a shell command to find the common items between two files given.  This is the beginning of my PHP script:</p>
  
  <pre><code>$E7Bonded_File = "/opt/IBM/custom/NAC_Dslam/junk/PortParameter_E7_Bonded_cust_stats.csv";
  $E7Single_File = "/opt/IBM/custom/NAC_Dslam/junk/PortParameter_E7_Single_cust_stats.csv";
  $E7Common_File = "/opt/IBM/custom/NAC_Dslam/junk/Common_tn_SingleBonded_E7_cust_stats.csv";
  //only do this once, with old single/bonded filenames. This will be a list to add to the existing Common file.
  exec ("comm -12 &lt;(cut -d ',' -f2 $E7Single_File| sort) &lt;(cut -d ',' -f2 $E7Bonded_File| sort)", $outputCommon); 
  </code></pre>
  
  <p>I see this error message when I run the script:</p>
  
  <pre><code>sh: -c: line 0: syntax error near unexpected token `('
  sh: -c: line 0: `comm -12 &lt;(cut -d ',' -f2 /opt/IBM/custom/NAC_Dslam/junk/PortParameter_E7_Single_cust_stats.csv| sort) &lt;(cut -d ',' -f2 /opt/IBM/custom/NAC_Dslam/junk/PortParameter_E7_Bonded_cust_stats.csv| sort)'
  </code></pre>
  
  <p>I checked, and the parentheses look ok for my <code>exec()</code> line.</p>
  
  <p>When I run the shell command at the command line it returns a listing of numbers like I expect:</p>
  
  <pre><code> comm -12 &lt;(cut -d ',' -f2 junk/PortParameter_E7_Single_cust_stats.csv| sort) &lt;(cut -d ',' -f2 junk/PortParameter_E7_Bonded_cust_stats.csv| sort)
  </code></pre>
  
  <p>I looked online and I seem to be using <code>exec()</code> correctly.  I want the numbers returned to be stored as an array, <code>$outputCommon</code>.</p>
  
  <p>Any ideas about this error message?</p>
  
  <p>*********Update on answer***************</p>
  
  <p>My solution wound up being a combination of both mario and miken32/my co-worker</p>
  
  <ol>
  <li>Adding <code>#!/bin/bash</code> at the top of my php script, and </li>
  <li><p>Adding <code>/bin/bash -c</code>  as follows:</p>
  
  <p>exec("/bin/bash -c /opt/IBM/custom/NAC_Dslam/Common_list.sh", $outputShell);</p></li>
  <li><p>After I moved the comm part to a shell script:</p></li>
  </ol>
  
  <p>Common_list.sh:</p>
  
  <pre><code>#!/bin/bash
   comm -12 &lt;(cut -d ',' -f2 /opt/IBM/custom/NAC_Dslam/junk/PortParameter_E7_Single_cust_stats.csv| sort) &lt;(cut -d ',' -f2 /opt/IBM/custom/NAC_Dslam/junk/PortParameter_E7_Bonded_cust_stats.csv| sort)
  </code></pre>