![]() |
basic athentication with python
so all i want is a smaal program wich is called in command line:
Code:
auth.pyand it should return OK or ERR it should only check one username and password and it would be hardcoded in it :) so I have somthing like this (parts of it stolen from somewhere): Code:
#!/usr/bin/pythonCode:
root@monstrs:/etc/squid# ./custom_auth.py |
Just as it says, you have sys.stdin.strip() -- where sys.stdin is a file object and you're trying to call a non-existent method strip() on it. I think you meant line.strip() or attach the strip() to the readline() on the prior source line.
Another problem that will come up is you have line.fine() rather than line.find(). And you don't effectively handle the case where there is no space. matchpasswd() should be returning True or False, not setting x to zero or one. You would probably be better served by print or print() [Python 3] than sys.stdout.write() and sys.stdout.flush(). |
ok so far so good (i'm completly new to python) how do i return that a function is true?
|
Code:
return True |
hmm that part now looks like this:
Code:
def matchpasswd(login, password):Code:
File "./custom_auth.py", line 8 |
| All times are GMT -5. The time now is 08:51 PM. |