Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys, os, socket, subprocess, getpass
- if len(sys.argv) < 5:
- print "Usage: <IP/hostname> <command> <username> <password/->"
- sys.exit(1)
- # Make sure our directory exists
- rdesktop_dir=os.path.expanduser('~/.rdesktop/')
- if not os.path.exists(rdesktop_dir):
- os.mkdir(rdesktop_dir)
- # Check for existing socket
- socket_path=rdesktop_dir+'socket-'+sys.argv[1]+'-'+sys.argv[3]
- if os.path.exists(socket_path):
- # We have a socket so try to use it
- try:
- s=socket.socket(socket.AF_UNIX)
- s.connect(socket_path)
- s.send(sys.argv[2])
- s.close()
- sys.exit(0)
- except:
- # We failed to start the command so re-establish the socket
- pass
- else:
- # We don't have a socket so start rdesktop from scratch
- # Check if we were supplied a password
- if sys.argv[4] == '-':
- sys.argv[4] = getpass.getpass()
- # Build a parameter list
- cmd=['rdesktop',
- '-a','16',
- '-u',sys.argv[3],
- '-p',sys.argv[4],
- '-s','c:\seamlessrdp\seamlessrdpshell.exe '+sys.argv[2],
- '-d','RLNX',
- '-x','l',
- '-r','sound:local',
- '-r','clipboard:PRIMARYCLIPBOARD',
- '-k','en-us',
- '-A',
- '-M',socket_path,
- sys.argv[1]
- ]
- pid = os.fork()
- if pid == 0:
- process=subprocess.Popen(cmd)
- process.wait()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement