#!/usr/bin/env python3.5
import subprocess
import os
command=r'ssh <some-server> "(echo \"import os\" ; echo \"for r,d,f in os.walk('/etc/'): print (r,len(f))\")| python"'
ssh=subprocess.call(["bash","-c","{0}".format("command")])
print(ssh)
I'm trying to run the above code and the code gives the following error :
Traceback (most recent call last): File "./test_filelist.py", line 11, in command=r'ssh "(echo \"import os\" ; echo \"for r,d,f in os.walk('/etc/'): print (r,len(f))\")| python"' NameError: name 'etc' is not defined
How do I fix that , Is there something that I need to escape . Thanks in advance .