Jul-03-2020, 01:13 AM
I'm fairly new to python, and I have been trying to use the "getopt" module working in my script without success.
I troubleshoot, I removed all other code from my script and just worked with the code shown below. Working in the interactive shell, I have no problems getting output.
SCRIPT
--------------------------------------------------------
#!/usr/bin/python
import getopt
print getopt.getopt(['-a', '-bval', '-c', 'val'], 'ab:c:')
---------------
OUTPUT:
Traceback (most recent call last):
File "./test-getopt.py", line 3, in <module>
import getopt
File "/home/nnevarez/HTB/SCRIPTS/getopt.py", line 23, in <module>
#
TypeError: 'module' object is not callable
INTERACTIVE
-------------------------------------------------------
>>> import getopt
>>>
>>>
>>> print getopt.getopt(['-a', '-bval', '-c', 'val'], 'ab:c:')
([('-a', ''), ('-b', 'val'), ('-c', 'val')], [])
>>>
-------------------------------------------------------
I troubleshoot, I removed all other code from my script and just worked with the code shown below. Working in the interactive shell, I have no problems getting output.
SCRIPT
--------------------------------------------------------
#!/usr/bin/python
import getopt
print getopt.getopt(['-a', '-bval', '-c', 'val'], 'ab:c:')
---------------
OUTPUT:
Traceback (most recent call last):
File "./test-getopt.py", line 3, in <module>
import getopt
File "/home/nnevarez/HTB/SCRIPTS/getopt.py", line 23, in <module>
#
TypeError: 'module' object is not callable
INTERACTIVE
-------------------------------------------------------
>>> import getopt
>>>
>>>
>>> print getopt.getopt(['-a', '-bval', '-c', 'val'], 'ab:c:')
([('-a', ''), ('-b', 'val'), ('-c', 'val')], [])
>>>
-------------------------------------------------------