Reputation: 1071
The goal here is to get a key or p/w from a website.
In Python, I have tried both os.system() and subprocess.call([]) to run following linux command but both method ends up with error.
os.system("curl -s http://example.com | grep ' "Key" : * ' | cut -f1 -d " " | cut -b5- | rev | cut -b9- | rev")
In linux following is being used and that works fine.
PW = 'curl -s http://example.com | grep ' "Key" : * ' | cut -f1 -d " " | cut -b5- | rev | cut -b8- | rev'
The error I see is SyntaxError: invalid syntax and it points at the "key" part
Upvotes: 0
Views: 35
Reputation: 51335
You probably just need to escape your double quotes. Try:
os.system("curl -s http://example.com | grep ' \"Key\" : * ' | cut -f1 -d \" \" | cut -b5- | rev | cut -b9- | rev")
Upvotes: 3