[SOLVED] Python - SyntaxError: invalid syntax
by czezz from LinuxQuestions.org on (#5HJHZ)
I am trying to reuse following python code to check host and port connectivity.
https://gist.github.com/betrcode/0248f0fda894013382d7
Code:import socket
def isOpen("192.168.56.104",22):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((ip, int(port)))
s.shutdown(2)
return True
except:
return FalseThe problem is that it does not work at all and its hard to me to figure out what is the issue (i just started with python today).
Seems like it does not like quota. But no matter what I try - change to single quota or remove quota completely - the error stays the same
Code:./con.py
File "./con.py", line 11
def isOpen("192.168.56.104",22):
^
SyntaxError: invalid syntax


https://gist.github.com/betrcode/0248f0fda894013382d7
Code:import socket
def isOpen("192.168.56.104",22):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((ip, int(port)))
s.shutdown(2)
return True
except:
return FalseThe problem is that it does not work at all and its hard to me to figure out what is the issue (i just started with python today).
Seems like it does not like quota. But no matter what I try - change to single quota or remove quota completely - the error stays the same
Code:./con.py
File "./con.py", line 11
def isOpen("192.168.56.104",22):
^
SyntaxError: invalid syntax