我得到一个错误,我认为是由我的使用说明引起的,但无法解决原因。我们的想法是获取文件中的有效用户列表(用户名密码),将其拆分为字典并返回字典。然后获取服务器文件(ip perline),将其转换为列表。然后生病调用一个子进程到mtstc,填充.rdp配置文件或直接在cli上输入信用证(还没有到目前为止)
任何帮助都将不胜感激。
错误
unknown@ubuntu:~$ ./rdpcheck.py -u userpass.txt -s servers.txt
Traceback (most recent call last):
File "./rdpcheck.py", line 30, in <module>
arguments = docopt(__doc__, version='0.1a')
File "/usr/local/lib/python2.7/dist-packages/docopt.py", line 560, in docopt
pattern = parse_pattern(formal_usage(DocoptExit.usage), options)
File "/usr/local/lib/python2.7/dist-packages/docopt.py", line 373, in parse_pattern
result = parse_expr(tokens, options)
File "/usr/local/lib/python2.7/dist-packages/docopt.py", line 387, in parse_expr
seq = parse_seq(tokens, options)
File "/usr/local/lib/python2.7/dist-packages/docopt.py", line 396, in parse_seq
atom = parse_atom(tokens, options)
File "/usr/local/lib/python2.7/dist-packages/docopt.py", line 415, in parse_atom
raise tokens.error("unmatched '%s'" % token)
docopt.DocoptLanguageError: unmatched '('
CODE
#!/usr/bin/python
"""
Script to check valid login credentials have ability to rdp to list of server.
Usage:
rdpcheck.py (-u <user>) (-s <server>)
rdpcheck.py -h | --help
Options:
-u --user
-s --server
-h --help This help screen this screen.
"""
from docopt import docopt
def getuserpass(userpass):
list = {}
with open(userpass, 'r') as text:
for line in text:
key, value = line.split()
return list
def getservers(servers):
slist = open(servers).readlines()
return [s.replace('\n', '.') for s in slist]
if __name__ == "__main__":
arguments = docopt(__doc__, version='0.1a')
print arguments
答案 0 :(得分:0)
似乎我错过了--version选项。
新代码
#!/usr/bin/python
"""
Description:
Users to test a list of credentials against a list of servers
Usage:
rdpcheck.py (-u <FILE>) (-s <FILE>)
rdpcheck.py -h | --help
rdpcheck.py --version
Options:
-h --help Show this screen.
--version Show version.
-u --user=FILE
-s --server=FILE
"""
from docopt import docopt
def getuserpass(userpass):
list = {}
with open(userpass, 'r') as text:
for line in text:
key, value = line.split()
return list
def getservers(servers):
slist = open(servers).readlines()
return [s.replace('\n', '.') for s in slist]
if __name__ == "__main__":
arguments = docopt(__doc__, version='0.1a')
print arguments