title: how to run Python script from php
body: <p>I want to run python script from php.
  this is my python code. It is saved in /home/pi and name of file is hello.py</p>
  
  <pre><code>#! /usr/bin/python
  
  import bluetooth
  
  bd_addr="xx:xx:xx:xx:xx:xx"
  port=1
  sock=bluetooth.BluetoothSocket(bluetooth.RFCOMM)
  sock.connect((bd_addr.port))
  data=""
  while 1:
    try:
      data +=sock.recv(1024)
      data_end=data.find('\n')
      if data_end!=-1:
        rec=data[:data_end]
        print datas
        data=data[data_end+1:]
      except KeyboardInterrupt:
        break
  </code></pre>
  
  <p>And here is my php code. It is saved in /var/www/html and name of file is php.php</p>
  
  <pre><code>&lt;?php
  $output=shell_exec('ls -l /home/pi/hello.py');
  echo "&lt;pre&gt;$output&lt;/pre&gt;";
  ?&gt;
  </code></pre>
  
  <p>And I insert localhost/php.php in chrome, it displays</p>
  
  <pre><code>-rw-r-r- 1 pi pi 378 Mar 8 12:07 /home/pi/hello.py
  </code></pre>
  
  <p>what is the problem??</p>