시스템 관리를 하다 윈도우 방화벽 상태를 주기적으로 체크해야 할 일이 있어서 간단히 파이썬과 명령어를 조합하여
만들어 보았다.
subprocess.check_output : 명령어 결과를 문자열로 리턴 받음
import subprocess
if 'ON' in str(subprocess.check_output(['netsh', 'advfirewall', 'show', 'currentprofile', 'state'], universal_newlines=True)):
print('Windows Firewall State ON')
else:
print('Windows Firewall State OFF')
RESULT : Windows Firewall State ON
RESULT : Windows Firewall State OFF
'Python > Python for Windows' 카테고리의 다른 글
[Python] subprocess와 DOS명령어를 이용한 Windows 계정 자동 생성 (0) | 2020.10.16 |
---|---|
[Python] subprocess모듈과 7z을 이용한 전일 로그 자동 압축 보관 (0) | 2019.10.24 |
[Python] subprocess모듈과 Bandizip을 이용한 전일 로그 자동 압축 보관 (0) | 2019.10.20 |
[Python] To send an attachment when mailing (0) | 2019.09.30 |
[Python] pandas를 이용한 iis-ftp log 파싱 (0) | 2019.09.16 |
[Python] psutil을 이용한 프로세스/로컬IP/로컬Port/리모트IP/리모트Port 모니터링 (0) | 2019.09.08 |
[Python] Check ICMP using ping3 module, maria db and grafana (0) | 2019.08.25 |
[Python] winreg 모듈을 이용한 Windows 공유폴더 레지스트리 설정 점검 (0) | 2019.08.24 |