Currently calling:
f = open('/tmp/list.txt','w')
f.write(list)
f.close() # Make sure to close the file before call sub-process.
# Otherwise, file content will not visible to sub-process.
process = subprocess.Popen('oscommand --file={}'.format(f.name),
shell=True, stdout=subprocess.PIPE)
However need to use a variable as an argument which has been generated using [ShortId][1]. Need something like:
u=ShortId()
process = subprocess.Popen('oscommand --label "The unique id is "'+u' --file={}'.format(f.name),
shell=True, stdout=subprocess.PIPE)
How is the escaping best handled ?
.format(str(u))?Popencommand. You can format the string and save it as a variable before you pass it in.