comm = f"curl -Ivs https://{host}.{name}:{port} --connect-timeout 5" result = subprocess.getstatusoutput(comm) f.write(result[1]) status_code = result[0] m = re.search(r'Trying (.*?)...\n.*?subject:.*? CN=(.*?)\n.*?start date: (.*?)\n.*?expire date: (.*?)\n', f.getvalue(), re.M | re.S)