sshNetstat = getoutput("netstat -t | grep :ssh.*ESTABLISHED").split("\n") try: if not "ESTABLISHED" in sshNetstat[0]: sshNetstat = [] except: pass