Output System Information
#!/bin/bashif [$#-eq 0];then echo "---------------------------------------------------------------------------" # OS type echo "OS Type: $ (uname-o)" # OS Release Version and Name echo " OS Release Version and Name: $ (cat/etc/issue | head-n 1) "#Architecture echo" Architecture: $ (uname-m) "#Kernel release echo" Kernel release: $ (uname-r) "#hostname echo" Hostname: $HOSTNAME "#Internal IP echo" Internal IP: $ (hostname-i) " #External IP echo "External IP: $ (curl-s ipecho.net/plain)" #DNS dnsservers= "" For I in $ (cat/etc/resolv.conf | grep ' ^nameserver ' | awk ' {print $NF} ') do dnsservers= "$dnsse Rvers$i "Done Echoes" DNS: $dnsservers "#if connected to the Internet or not echo "inteRnet Status: $ (ping-c 2 www.baidu.com &>/dev/null && echo ' Connected ' | | echo ' disconnected ') "EC Ho "---------------------------------------------------------------------------" fi
Output Result:
OS Type:gnu/linuxos release Version and Name:centos release 6.6 (Final) architecture:x86_64 Kernel release:2.6 .32-504.el6.x86_64 hostname:wap Internal ip:192.168.110.173 External ip:218.30.109.26 DNS: 218.30.105.51 219.141.140.10 Internet status:connected
Shell programming-instance output system Information