Right now I have a test file.dat that I run hexdump on and put the output into a hexdump.dat file.
subprocess.Popen(['hexdump file.dat > hexdump.dat' ], shell=True)
As a side note, I have seen suggestions to not use shell=True
but I essentially get the error OSError: [Errno 2] No such file or directory
.
So, I would like to be able to pass in a variable or an array, files, instead of the hardcoded "file.dat". "files" could be a user input or an array/list generated from a previous subprocess section.
I have tried a user input case:
from subprocess import Popen, PIPE, STDOUT
files = raw_input('File Name: ')
p = subprocess.Popen(['hexdump files > hexdump.dat' ], stdout=PIPE, stderr=STDOUT)
out,err = p.communicate(input=files)
Also with:
p = subprocess.Popen(['hexdump', inputs, ' > hexdump.dat' ], stdout=PIPE, stderr=STDOUT)
Thanks for the help, I know I'm not appropriately understanding the structure needed here so some "handholdy" answers would be appreciated.