Self-Improvement

13) 쉘 프로그래밍 실습3 (echo escape character) 본문

프로그래밍/Shell

13) 쉘 프로그래밍 실습3 (echo escape character)

JoGeun 2018. 10. 21. 13:00

*ping 테스트 프로그램
 #vi ping.sh




 #chmod 755 ping.sh
 #ping.sh




*네트워크 점검 프로그램
 #vi functions.sh



 ※functions는 색상이 정의된 함수이며 이용한다.

 #vi check_network.sh 
-----------check_network.sh--------------
 #!/bin/bash
. functions.sh
LAN1() {
 print_error "[ FAIL ] Local Network Connection"
 echo "(ㄱ) VMware >  Edit > Virtual Network Editor"
 echo "(ㄴ) VMware > VM > Settings > Network Adapter"
 echo "(ㄷ) #ifconfig"
}
GATE1() {
 print_error "[ FAIL ] Local Network Connection"
 echo "(ㄱ) #netstat -nr (# route -n)"
}
DNS1() {
 print_error "[ FAIL ] Local Network Connection"
 echo "(ㄱ) #cat /etc/resolv.conf"
}
print_info "ping -c 1 172.16.6.249"
ping -c 1 172.16.6.249 >> /dev/null 2>&1
if [ $? -eq 0 ] ; then
 print_good "[  OK  ] Local Network Connection"
else
 LAN1
 exit 1
fi
print_info "ping -c 1 168.126.63.1"
ping -c 1 168.126.63.1 >> /dev/null 2>&1
if [ $? -eq 0 ] ; then
 print_good "[  OK  ] External Netwrok Connection"
else
 GATE1
 exit 2
fi
print_info "nslookup www.daum.net"
nslookup www.daum.net | grep 'connection timed out' >> /dev/null 2>&1
if [ $? -eq 1 ] ; then
 print_good "[  OK  ] DNS Client Configuration"
else
 DNS1
 exit 3
fi
 ----------------------------------
 #chmod 755 check_network.sh
 #check_network.sh




*echo CMD의 escape character이용
 \b     backspace
 \n     new line
 \r     carriage return

 ex) echo -ne "Hello\r"
 ※#man bash --> /escape character (매뉴얼)

 1.
 #vi test.sh




 #chmod 755 test.sh
 #test.sh






 2.
 #vi test2.sh




 #chmod 755 test2.sh
 #test2.sh



 3.
 #vi test3.sh (종합)



 
 #chmod 755 test3.sh
 #test3.sh








*서버 취약점 점검 스크립트
 #vi server_check.sh




 #chmod 755 server_check.sh
 #server_check.sh




*Language 배우는 참고사이트
 https://www.codecademy.com/tracks/python