Created
March 3, 2014 19:02
-
-
Save Zagrebelin/9332161 to your computer and use it in GitHub Desktop.
telnet: protocol handler. Actualy it's wrapper around SecureCrt.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urlparse | |
import sys | |
from subprocess import Popen | |
urlparse.uses_params += ['telnet',] | |
class HelpException(Exception): | |
pass | |
def help(): | |
print "telnet_handler.py [telnet://host:port/;param1=value1¶m2=value2] [/register] [/deregister]" | |
def start_securecrt(host, params): | |
params = [ '/%s=%s' % p for p in params ] | |
params.insert(0, host) | |
params = ' '.join(params) | |
print params | |
exe = "C:\\Program Files\\VanDyke Software\\Clients\\SecureCRT.exe" | |
Popen( (exe, params) ) | |
def main(): | |
print urlparse.uses_params | |
if len(sys.argv)!=2: | |
raise HelpException() | |
if sys.argv[1]=='/register': | |
register() | |
elif sys.argv[1]=='/deregister': | |
deregister() | |
else: | |
o = urlparse.urlparse(sys.argv[1]) | |
host = o.netloc | |
params = o.params.strip('?') | |
params = urlparse.parse_qsl(params) | |
start_securecrt(host, params) | |
if __name__=="__main__": | |
try: | |
main() | |
except HelpException: | |
help() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment