Article 5HJHZ [SOLVED] Python - SyntaxError: invalid syntax

[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 syntaxlatest?d=yIl2AUoC8zA latest?i=ng1CRvmdC5c:Y3MWRkhBd0E:F7zBnMy latest?i=ng1CRvmdC5c:Y3MWRkhBd0E:V_sGLiP latest?d=qj6IDK7rITs latest?i=ng1CRvmdC5c:Y3MWRkhBd0E:gIN9vFwng1CRvmdC5c
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments