目录
1.list_net_info.sh
#!/bin/bash
IP=`ifconfig eth0 | head -2 | tail -1 | awk '{print $2}' | awk -F":" '{print $2}'`
ZW=` ifconfig eth0 | head -2 | tail -1 | awk '{print $3}' | awk -F":" '{print $2}'`
GW=`route -n | tail -1 | awk '{print $2}'`
HN=`hostname`
DNS=`head -1 /etc/resolv.conf | awk '{print $2}'`
echo '此机IP地址是' $IP
echo '此机子网掩码是' $ZW
echo '此机网关是' $GW
echo '此机主机名是' $HN
echo '此机DNS是' $DNS
2.virtuoso_1.sh[自动将某个文件夹下的文件添加到cds.lib中(有可能会添加重复的语句)]
#!/bin/bash
#this file is designed for this kind of situation
#the libraries are in dir A, and there are a number of libraries
#and the cds.lib is at anywhere accessible
#and this file is to add these libraries into the cds.lib
num=$(ls -l | wc -l )
echo "number is $(($num - 1))"
#echo $(ls -l) | xargs -0 cut -d '' -f 9
file_list=`ls -l | tail -7 | cut -d : -f 2 | cut -d ' ' -f 2 `
echo $file_list
echo "input the position of cds.lib file:"
read cdspos
if [ $cdspos = '.' ]
then
cdspos=`pwd`
else
sleep 1
fi
echo "cdspos is $cdspos"
echo "#############################################this is newly added#############################"
for i in $file_list
do
str="$cdspos/$i"
echo $str >> cds.lib
done
echo "done"
3.ip_online.sh
#!/bin/bash
#输出192.168.1.0/255网段内在线主机的ip地址
#统计不在线主机的台数,并把不在线主机的ip地址和不在线时的时间保存到/tmp/ip.txt文件里
#!/bin/bash
ip=192.168.1.
j=0
for i in `seq 1 255`
do
ping -c 3 $ip$i &> /dev/null
if [ $? -eq 0 ];then
echo 在线的主机有:$ip$i
else
let j++
echo $ip$i >> /tmp/ip.txt
date >> /tmp/ip.txt
fi
done
echo 不在线的主机台数有 $j
4.