It looks like you're new here. If you want to get involved, click one of these buttons!
python script.py -1 --arg1 -p 20
nc -l 20
import optparse
parser = optparse.OptionParser()
Options = optparse.OptionGroup(parser, 'Options')
parser.add_option('-s', '--host',
action='store', type='string', help=\"Remote host\", metavar=\"HOST\")
parser.add_option('-u', '--udp',
action=\"store_true\", help=\"Use UDP\")
import optparse
parser = optparse.OptionParser()
Options = optparse.OptionGroup(parser, 'Options')
parser.add_option('-1', '--arg1',
action='store', type='string', help=\"Argument one\")
parser.add_option('-2', '--arg2',
action=\"store\", type='string', help=\"Argument two\")
parser.add_option_group(Options)
(opts, args) = parser.parse_args()
if opts.arg1:
print(\"Argument one was %s\" % opts.arg1)
if opts.arg2:
print(\"Argument two was %s\" % opts.arg2)
else:
print(\"Need an argument!\")
chronic@vandal:/tmp$ python opts.py -1 iexploit -2 rocks
Argument one was iexploit
Argument two was rocks
chronic@vandal:/tmp$ python opts.py -2 rocks -1 iexploit
Argument one was iexploit
Argument two was rocks
chronic@vandal:/tmp$ python opts.py -h
Usage: opts.py [options]
Options:
-h, --help show this help message and exit
-1 ARG1, --arg1=ARG1 Argument one
-2 ARG2, --arg2=ARG2 Argument two
Options: