title: Standard output in bash blocked by a line of code
body: <p>I have a bash script in which I call a python script:</p>
  
  <pre><code>#!/bin/bash
  python myscript.py
  </code></pre>
  
  <p>In the python script I'm using the selenium package to scrape:</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  print('starting')
  chrome_options = webdriver.ChromeOptions()
  chrome_options.add_argument('--headless')
  chrome_options.add_argument('--no-sandbox')
  chrome_options.add_argument('--disable-dev-shm-usage')
  browser = webdriver.Chrome("/chromedriver",chrome_options=chrome_options)
  url = "https://example.com"
  browser.get(url)
  ...
  </code></pre>
  
  <p>I would like to run the bash script and get the output to the console and to a log file:</p>
  
  <pre><code>./bash_script.sh 2&gt;&amp;1 | tee log.txt
  </code></pre>
  
  <p>My problem is that this command never prints the expected message "starting" (or any other <code>print</code> in the python script), although the python script is indeed running.</p>
  
  <p>BUT:</p>
  
  <ol>
  <li>If I remove the <code>browser.get(url)</code> command, it works </li>
  <li>If I call directly the python script (not through the bash script),
  it works</li>
  <li>If I don't redirect the output and just call <code>./bash_script.sh</code>, it
          works</li>
  </ol>
  
  <p>so it looks like there is a weird interaction between the bash redirection and this specific line of code <code>browser.get(url)</code></p>
  
  <p>Any idea why and how I can fix that?</p>