I am trying to get the output of a shell command
I try to execute using python
but I get an error.
How can I get the response/return value from executing a bash command
This is what I have done:
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)
Somehow this gives an error:
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
Can someone please help me to print the response without getting this error (from python)?