-
<PYTHON>[에러 처리 (try-except, traceback)]Flower in my dev/Python 2015. 5. 11. 12:53
[try-except] try : #에러 발생 예상 코드 except Exception, msg : #에러 발생시 실행 코드 print "Error is : %s" % str(msg) pass [traceback] import traceback traceback.print_exc() 에러스택을 stdout으로 출력 errStr = traceback.format_exc() 에러스택을 string으로 반환
-
iptalbesFlower in my ops/Linux 2015. 5. 8. 10:43
iptalbes란? iptables란 넷필터 프로젝트에서 개발했으며 광범위한 프로토콜 상태 추적, 패킷 애플리케이션 계층검사, 속도 제한, 필터링 정책을 명시하기 위한 강력한 매커니즘을 제공한다. 서비스 등록과 시작 CentOS 6.4 Minimal에는 iptables가 설치되어 있다. ip6tables도 함께 설치되어 있는데 이는 IPv6 체계에서 사용한다.rpm -qa | grep iptables iptables-1.4.7-9.el6.x86_64 iptables-ipv6-1.4.7-9.el6.x86_64 설치되어 있지 않다면 설치yum -y install iptables 상태 확인chkconfig --list ip6tables 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제 iptabl..
-
<PYTHON>[subprocess]Flower in my dev/Python 2015. 5. 7. 10:39
파이썬에서 시스템 명령을 실행하는 방법 중에 하나이다. 1 2 3 import subprocess subprocess.call('ls -al', shell=True) cs subprocess를 모듈로 등록하고 call을 불러서 사용하면 끝이다. 결과를 리턴 받고 싶다면 result = subprocess.check_output('명령', shell=True) 그리고 result를 가지고 조건을 걸어 사용하면 끝. ==================== Popen을 사용하는 방법 12345import subprocess r = subprocess.Popen('ls', stdout=subprocess.PIPE).stdout rs = r.read().strip()Colored by Color Scriptercs..
-
grepFlower in my ops/Linux 2015. 4. 30. 10:59
grep [-옵션] 패턴 파일명 grep [OPTIONS] PATTERN [FILE...] -c : 패턴이 일치하는 행의 수를 출력 -c, --count Suppress normal output; instead print a count of matching lines for each input file. With the -v, --invert-match option (see below), count non-matching lines. (-c is specified by POSIX.) -i : 비교시 대소문자를 구별 안함 -i, --ignore-case Ignore case distinctions in both the PATTERN and the input files. (-i is specified by ..
-
서버 용량 확인 [df, du]Flower in my ops/Linux 2015. 4. 30. 10:41
df : 디스크의 남은 용량을 확인 df -k : 킬로바이트 단위로 현재 남은 용량을 확인 df -m : 메가바이트 단위로 남은 용량을 왁인 df -h : 보기 좋게 보여줌 df . : 현재 디렉토리가 포함된 파티션의 남은 용량을 확인 -a, --all 파일 시스템의 크기가 0인 것도 모두 보여준다. 초기값은 제외 시킨다. 이런 파일 시스템은 전형적으로 자동 마운트관련, 특별 구성, pseudo-filesystems이다. 어떤 시 스템에서는 ‘‘ignore’’, 또는 ‘‘auto’’ 형태의 파일 시스템이 초기값으로 생략되는 경우가 있다. 이때 이옵션을 사용한다. -i, --inodes 블럭 사용 정보 대신에 inode 사용정보를 보여준다. inode란 특별한 종류의 디스크 블럭인데, 이것은 파일이름, 소..