I'm using WLST to execute some scripts to deploy some applications in Weblogic.
I'm using getopt library in Python to parser command line arguments.
I created a script to download some files by FTP.
To do this, the user must inform the 'ftpurl', 'ftpusername' e 'ftppassword' options and respective values.
import getopt
# -*- coding: utf-8 -*-
#=======================================================
# MAIN
#=======================================================
args = sys.argv
print 'Informed arguments: '
print args
for index in range(len(args)):
if (":\\" in args[index]) :
print
print 'Removing arguments with file path'
print args[index]
del args[index]
break
optlist, argsNotExpected = getopt.getopt(args, '', ['ftpurl=', 'ftpusername=', 'ftppassword='])
print
print 'Found options: '
print optlist
print
print 'Not expected arguments: '
print argsNotExpected
The argument value "test123!@#$%*()_-" that have many special characteres works.
java weblogic.WLST C:\\Ambiente\\scripts\\python\\getoptTest.py --ftpurl=ftp.test.com --ftppassword=test123!@#$%*()_- --ftpusername=usertest
Result:
Informed arguments:
['C:\\\\Ambiente\\\\scripts\\\\python\\\\getoptTest.py', '--ftpurl=ftp.test.com', '--ftppassword=test123!@#$%*()_-', '--ftpusername=usertest']
Removing arguments with file path
C:\\Ambiente\\scripts\\python\\getoptTest.py
Found options:
[('--ftpurl', 'ftp.test.com'), ('--ftppassword', 'test123!@#$%*()_-'), ('--ftpusername', 'usertest')]
Not expected arguments:
[]
But when I passing "test&123!@#$%*()_-" with "&" character, the value is break and the rest of the arguments are ignored starting from "&".
java weblogic.WLST C:\\Ambiente\\scripts\\python\\getoptTest.py --ftpurl=ftp.test.com --ftppassword=test&123!@#$%*()_- --ftpusername=usertest
Result:
Informed arguments:
['C:\\\\Ambiente\\\\scripts\\\\python\\\\getoptTest.py', '--ftpurl=ftp.test.com', '--ftppassword=test']
Removing arguments with file path
C:\\Ambiente\\scripts\\python\\getoptTest.py
Found options:
[('--ftpurl', 'ftp.test.com'), ('--ftppassword', 'test')]
Not expected arguments:
[]
'123!@#$%*' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
Can anyone give a tip?