I am running cat
command to read the Linux version using subprocess.run()
. However it doesn't work, the error is: cat: '/etc/*-release': No such file or directory
, and I can not use shell=True
due to security. Any hints how to solve this is appreciated.
Here is my code:
try:
result = subprocess.run(
shlex.split("cat /etc/*-release"),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True)
except subprocess.TimeoutExpired as err:
result = err