0

I keep getting IndexError: list index out of range when using the below snippets in a python script:

rhost = sys.argv[1] #target ip
rport = int(sys.argv[2]) #target port

I do not really see the issue with the above code. Any assistance would be most appreciated!

ekhumoro
  • 115,249
  • 20
  • 229
  • 336
v3ga
  • 23
  • 1
  • 6

2 Answers2

0

It seems like sys.argv does not have 2 or more entries. If you call your script with commandline arguments the list has more than one entry. Do you do that? See this post for a very detailed description on how it works: sys.argv[1] meaning in script

lkriener
  • 187
  • 2
  • 7
0

It was my mistake, I need to add a logic check in the script so that if there is not the appropriate amount of arguments it displays an error referencing the usage portion.

v3ga
  • 23
  • 1
  • 6