0

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

1 Answer 1

3

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") 
Sign up to request clarification or add additional context in comments.

1 Comment

You are right, that was the problem. Code runs correctly now, but how do I assign output of this code to a new variable ? I mean I tried doing pass = os.system(....) but it just prints the key but when I check the variable it returns 0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.