title: PHP->bash->python Output
body: <pre><code>&lt;?php
  ini_set('display_errors', 1);
  ini_set('display_startup_errors', 1);
  error_reporting(E_ALL);
  passthru(&quot;bash /var/www/html/init.sh 2&gt;&amp;1&quot;,$pass_result);
  echo $pass_result; 
  ?&gt;
  </code></pre>
  <p>I am unable to get the python result at PHP level.
  The python script print(&quot;string&quot;) to the bash script and if I do</p>
  <pre><code>#!/bin/sh
  START=$(python3 /usr/lib/cgi-bin/test.py)
  echo &quot;${START}&quot;
  </code></pre>
  <p>This works if I run the bash script, it outputs the string on the terminal
  but if I call it from the PHP, it finishes immediately with this
  error:</p>
  <pre><code>#PHP OUTPUT
  /usr/lib/python3/dist-packages/requests/__init__.py:89: 
  RequestsDependencyWarning: urllib3 (1.26.0) or chardet (3.0.4) doesn't match a supported version! warnings.warn(&quot;urllib3 ({}) or chardet ({}) doesn't match a supported &quot; Traceback (most recent call last): 
  File &quot;/usr/lib/cgi-bin/test.py&quot;, line 34, in driver = webdriver.Chrome(options=opts) 
  File &quot;/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chrome/webdriver.py&quot;, line 70, in __init__ super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], &quot;goog&quot;, 
  File &quot;/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chromium/webdriver.py&quot;, line 90, in __init__ self.service.start() 
  File &quot;/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py&quot;, line 98, in start self.assert_process_still_running() 
  File &quot;/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py&quot;, line 110, in assert_process_still_running raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1 0
  
  </code></pre>
  <p>If I put a while and a for the behavior becomes weird</p>
  <pre><code>#!/bin/sh
  START=python3 /usr/lib/cgi-bin/test.py &amp;
  BACK_PID=$!
  while kill -0 $BACK_PID ; do
          for (( i=0; i&lt;10; i++ )); do
              sleep 5
              echo &quot;WTF&quot; $i
          done
      echo &quot;${OUTPUT}&quot;
  done
  </code></pre>
  <p>with this code the bash script will get the output of the python string at around 8 iterations of the for loop running it directly on the terminal and this is the only way I got PHP to wait for the end of the bash script, and it returns all
  9 WTFs but no python string, I can't understand why it is not reaching the PHP.</p>
  <pre><code>#PHP OUTPUT
  /usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.0) or chardet (3.0.4) doesn't match a supported version! warnings.warn(&quot;urllib3 ({}) or chardet ({}) doesn't match a supported &quot; Traceback (most recent call last): 
  File &quot;/usr/lib/cgi-bin/test.py&quot;, line 34, in driver = webdriver.Chrome(options=opts) 
  File &quot;/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chrome/webdriver.py&quot;, line 70, in __init__ super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], &quot;goog&quot;, 
  File &quot;/usr/local/lib/python3.8/dist-packages/selenium/webdriver/chromium/webdriver.py&quot;, line 90, in __init__ self.service.start() 
  File &quot;/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py&quot;, line 98, in start self.assert_process_still_running() 
  File &quot;/usr/local/lib/python3.8/dist-packages/selenium/webdriver/common/service.py&quot;, line 110, in assert_process_still_running raise WebDriverException( selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 1 WTF 0 WTF 1 WTF 2 WTF 3 WTF 4 WTF 5 WTF 6 WTF 7 WTF 8 WTF 9 /var/www/html/init.sh: line 4: kill: (11275) - No such process 0
  </code></pre>