title: Python CGI to invoke another CGI script that runs a sensor in Raspberry
body: <p>I have a python CGI program (says: scrip1), that I am using to set values for some variable for another python CGI script (says: script 2) using web browser. I am using the script 2 to run a Lidar Sensor.  The problem is I can set the variable in script 2 using script 1. But script 2 is not executing after receiving variable. Script 2 suppose to start my sensor. Any possible solutions. (I would like to stick on CGI scripts)</p>
  
  <pre><code>#script 1
  
  #!/usr/bin/python
  
  import os
  import cgi
  import cgitb
  print("Content-Type: text/html\r\n")
  print("")
  print'''&lt;html&gt;
  &lt;head&gt;&lt;title&gt;Form to enter sleep time&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
  
  &lt;form action="/cgi-bin/test.py" method="post"&gt;
  
      &lt;html&gt;&lt;label&gt; enter sleep time&lt;/label&gt;
  
      &lt;input type="number" name="sleeptime"/&gt;
  
      &lt;input type="submit" name ="Submit" "&gt;&lt;/form&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;'''
  
  
  #### second script is######
  
  #!/usr/bin/python
  
  import os
  
  import cgi
  
  import cgitb
  
  import smbus
  
  import time
  
  print("Content-Type: text/html\r\n")
  
  form = cgi.FieldStorage()
  
  sleeptime = form.getfirst("sleeptime")    #getting value from script 1 (form data)
  
  #script to run the Lidar is as follows#
  
  bus=smbus.SMBus(1)
  
  addr=0x62
  
  while True:
      bus.write_byte_data(0x62,0x00, 0x04)  
  
      val_high=bus.read_byte_data(0x62,0x0f)  
  
      val_low=bus.read_byte_data(0x62,0x10)   
  
      dist_cm=val_high*256+val_low
  
      print (dist_cm , " cm ")
  
      time.sleep(sleeptime)
  </code></pre>