User/Device Authorization in Python and Other Languages

2 posts / 0 new
Last post
loonybawz
User/Device Authorization in Python and Other Languages

in Michael's Authorization example
i noticed he was running a bash script as a command
with arguments and using the exit return code
as a True/False boolean this would also allow us to write
in other languages too like perl, c, python, lua, php

-----------------------------------------------------------------------------
#!/usr/bin/env python
# This is a Python Clone of Michael's Example
# But Instead of Logging the Strings im Just Printing Them

import sys

VENDOR_ID = str(sys.argv[1])
PRODUCT_ID = str(sys.argv[2])
CLIENT_ID = str(sys.argv[3])
CLIENT_IP = str(sys.argv[4])
PRODUCT_SERIAL = str(sys.argv[5])

print ("Authorizing -> '%s' '%s' '%s' '%s' '%s'") % (VENDOR_ID, PRODUCT_ID, CLIENT_ID, CLIENT_IP, PRODUCT_SERIAL)

if "(loonybawz)" in CLIENT_ID:
print ("Authorized!")
exit(1)
else:
print ("NOT authorized")
exit(0)

-----------------------------------------------------------------------------

Michael
Thanks for the post. That may

Thanks for the post. That may help others.

Log in or register to post comments