title: How to get return value of a executed command in Python
body: <p>I am trying to get the output of a <code>shell command</code> I try to execute using <code>python</code> but I get an error.</p>
  
  <p><strong>How can I get the response/return value from executing a bash command</strong></p>
  
  <p>This is what I have done:</p>
  
  <pre><code>import subprocess
  import time
  
  # NAMESPACE = input("Namespace: ")
  
  # # Create a namespace
  # subprocess.call(["kubectl", "create", "namespace", NAMESPACE])
  
  # build a docker image to deploy the application
  DOCKER_OUTPUT = subprocess.call(["docker", "build", "-t", "banuka/node-web-app", "."])
  print("Docker output is: " + DOCKER_OUTPUT)
  </code></pre>
  
  <p>Somehow this gives an error:</p>
  
  <blockquote>
    <p>unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/jananath/Desktop/python-script/Dockerfile: no such file or directory
    Traceback (most recent call last):
      File "/home/jananath/Desktop/python-script/bitesize-platform-troubleshooter/test/test.py", line 11, in 
        print("Docker output is: " + DOCKER_OUTPUT)
    TypeError: can only concatenate str (not "int") to str</p>
  </blockquote>
  
  <p>Can someone please help me to print the response without getting this error (from python)?</p>