判断网络主机存活企业面试题4:写一个脚本,实现判断10.0.0.0/24网络里,当前在线用户的IP有哪些(方法有很多) #!/bin/sh#[ -f /etc/init.d/functions ] && . /etc/init.d/functionsfunction IP_count(){ for n in 10.0.0.{0..255} do IP_check=`nmap -sP $n|grep "Host is up"|wc -l` if [ ${…
局域网中分了很多网段,而IP地址使用情况也未知,前期也没有规划和记录,当新的主机需要使用固定IP的时候,能否第一时间知道哪个IP空闲就显得很重要了,如果一个一个去ping的话太浪费时间. 这里分享一个shell脚本检测当前哪些IP在用和不在用. 脚本如下: #!/bin/bash #先生成一个网段的IP文本 ippre="192.168.10." for i in {1..254} do echo "${ippre}$i" >>ip.txt done #…
最近需要做一个实时统计网络情况并统计误包率的脚本,下面是StackExchange上的一个剽窃,虽然不完全满足,但只可以输出一些信息 #!/bin/bash host=$ if [ -z $host ]; then echo "Usage: `basename $0` [HOST]" exit fi while :; do result=` -c $host | grep 'bytes from '` ]; then echo -e "`date +'%Y/%m/%d %H:…
1. shell 的$! ,$?, $$,$@ $n $1 the first parameter,$2 the second... $# The number of command-line parameters. $0 The name of current program. $? Last command or function's return value. $$ The program's PID. $! …
http://blog.chinaunix.net/uid-7553302-id-183648.html 1 shell 的$! ,$?, $$,$@ $n $1 the first parameter,$2 the second... $# The number of command-line parameters. $0 The name of current program. $? Last command or function'…