def nmapScan(tgtHost): nmapScan = nmap.PortScanner() nmapScan.scan(tgtHost, '22') state = nmapScan[tgtHost]['tcp'][22]['state'] return state