title: Run python script and display printed value on a website
body: <p>I have a Python script that prints the current value that is being sent from a PLC connected on the same network as my PC.</p>
  <pre><code>#!/usr/bin/python
  #fetchVar.py argument-with-plc-variable-name
  #some script to connect to PLC and fetch
  #current value of variable sent as argument
  print plcVar
  </code></pre>
  <p>The script works - meaning every time I run this script I got printed the updated value of the variable I want. Example:</p>
  <blockquote>
  <p>python fetchVar.py aiTemperature</p>
  <p>15</p>
  </blockquote>
  <p>That means, the current value in PLC of variable named &quot;aiTemperature&quot; is 15.
  I'm trying to display the printed temperature in a HTML page, this is what I got so far:</p>
  <pre><code>&lt;body onload=&quot;varupdate()&quot;&gt;
      &lt;script language=&quot;JavaScript&quot;&gt;
          var int=self.setInterval(&quot;varupdate()&quot;,2000); // update Temperature every two seconds
          
          function varupdate() {
              // somehow run &quot;python fetchVar.py aiTemperature&quot;
              var x = ????;       //The printed value from getVar.py should be saved here
              document.getElementById(&quot;var1&quot;).innerHTML=&quot;Current Temperature = &quot; + x;
          }
      &lt;/script&gt;
      &lt;div id=&quot;var1&quot;&gt;&lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  <p>Any ideas how I can achieve this?</p>