|
|
第 91 帖 | |
|
|
脚本 : DiskCheck
作者 : Nicky Wang 用途 : 检查磁盘空间使用情况 适用 : 文件服务器 功能 : 在config中设定允许的最大百分比,每天增长最大百分比,;如果有超出设定范围的,则会发mail通知相关人员。 前提 : 配置邮件服务器地址 =============DiskCheck.csh================= #!/bin/csh # ------------------------------------ # Check Disk Space and Send Mail to User # # ------------------------------------ # ----Declare variables-------------- set progpath = $0 set sourcedir = $progpath:h set a = `grep "server:" $sourcedir/DiskCheck.config` set servername = $a[2] set a = `grep "maxused:" $sourcedir/DiskCheck.config` set maxused = $a[2] set b = `grep "maxincrease:" $sourcedir/DiskCheck.config` set maxincrs = $b[2] set mails = `grep "mailto:" $sourcedir/DiskCheck.config` set b = `grep "mailday:" $sourcedir/DiskCheck.config` set mailday = $b[2] set UsedFlag = "F" set IncrsFlag = "F" #-----Check OS and write data to new log file------- set mOS = `uname` if ( $mOS == "HP-UX" ) then bdf > $sourcedir/DiskCheck.log.new else df -k > $sourcedir/DiskCheck.log.new endif #---Check if Current day have to send mail------ set a = `date` if ( $a[1] == $mailday ) then foreach mailto($mails) #----check if $mailto is a validate mail address---- set flag = `echo $mailto|awk -F@ '{print NF-1}'` if !( $flag == "0" ) then mailx -s $servername" Disk Usage Ratio Check (weekly)" $mailto < $sourw endif end endif #--set allused = `awk '{print $5}' $sourcedir/DiskCheck.log.new` set allused = `awk -F"%" '{print $1}' $sourcedir/DiskCheck.log.new | awk '{prin` #-----Check maxused disk space and send mail------ set index = 2 while ( $index <= $#allused ) #----check max value---- if ( $allused[$index] >= $maxused ) then set UsedFlag = "T" endif @ index = $index + 1 end if ( $UsedFlag == "T" ) then foreach mailto($mails) #----check if $mailto is a validate mail address---- set flag = `echo $mailto|awk -F@ '{print NF-1}'` if !( $flag == "0" ) then mailx -s $servername" Disk Usage Ratio Alarm Mail" $mailto < $sourcedirw endif end endif #------Check Increasing speed and send mail----- #-----Check old log exist----------------------- if ( -e $sourcedir/DiskCheck.log ) then set oldused = `awk -F"%" '{print $1}' $sourcedir/DiskCheck.log | awk '{print` set index = 2 while ( $index <= $#oldused ) #-----Check increasing speed----- @ incrs = $allused[$index] - $oldused[$index] if ( $incrs >= $maxincrs ) then set IncrsFlag = "T" endif @ index = $index + 1 end if ( $IncrsFlag == "T" ) then foreach mailto($mails) #----check if $mailto is a validate mail address---- set flag = `echo $mailto|awk -F@ '{print NF-1}'` if !( $flag == "0" ) then mailx -s $servername" Disk Usage Ratio Increasing Alarm Mail" $mailw endif end endif endif #------replace old log with the new one----- \mv $sourcedir/DiskCheck.log.new $sourcedir/DiskCheck.log ================DiskCheck.config================ #------------------------- #please set the check item #------------------------- #----set the server name---- server: C01BOD05 #----set the maximum used radio (%) of disk space you allowed maxused: 80 #----set the maximun daily increasing radio (%) speed you allowed maxincrease: 5 #----set mail address to Inform mailto: nicky_wang@hjtc.com.cn, wdl36@sohu.com #----set whick day to send mail every week mailday: Thu =============================================== 备注 : 新手,也许有些写的冗长,望指点! |
|
|
|
|
|
|
|
第 92 帖 | ||
|
|
标题: 回复: 解压脚本 引用:
__________________
Athlon 1000MHz 40G HD 256M DDR Gforce2 MX 32M OpenBSD on Vmware workstation 4 Debian Sarge (console only) Gentoo 暂停使用中 (D)Windows 2003 都别打我啊,呵呵 |
||
|
|
|
||
|
|
第 93 帖 | |
|
|
糟了,引用错了,呵呵,不好意思,版主能不能给删掉了?
|
|
|
|
|
|
|
|
第 94 帖 | ||
|
|
标题: 回复: 回复: 一个盗取别人passwd的shell脚本 引用:
我测试过了,明显和正常登陆的时候不一样。 |
||
|
|
|
||
|
|
第 95 帖 | |
|
|
那个盗取密码的脚本怎么回事?得在别人登陆的时候运行才有效啊。
__________________
昼短苦夜长 何不秉烛游 |
|
|
|
|
|
|
|
第 96 帖 | |
|
|
那个盗取密码的脚本怎么回事?得在别人的shell上运行才有效啊。
|
|
|
|
|
|
|
|
第 97 帖 | |
|
|
那个盗取密码的脚本怎么回事?得在别人的shell上运行才有效啊。
|
|
|
|
|
|
|
|
第 98 帖 | |
|
|
标题: C++源码 #include <string>
#include <vector> #include <algorithm> #include <iostream> class urlcode { private: std::vector < char >m_inenpear; std::vector < char >m_outenpear; std::vector < char >m_indepear; std::vector < char >m_outdepear; int toHex (const int &x) { return x > 9 ? x + 55 : x + 48; } public: urlcode () { } ~urlcode () { m_inenpear.clear (); m_outenpear.clear (); m_indepear.clear (); m_outdepear.clear (); } int encodeTransfer (std::vector < char >&inenpear) { m_inenpear = inenpear; std::vector < char >::iterator pinpear = m_inenpear.begin (); int tmpinpear; for (; pinpear != m_inenpear.end (); pinpear++) { tmpinpear = *pinpear; if (((0x40 < tmpinpear) && (tmpinpear < 0x5b)) || ((0x60 < tmpinpear) && (tmpinpear < 0x7b)) || ((0x2f < tmpinpear) && (tmpinpear < 0x3a))) { m_outenpear.push_back (*pinpear); } else { if (((0x08 < tmpinpear) && (tmpinpear < 0x0e)) || (tmpinpear == 0x20)) { m_outenpear.push_back ('+'); } else { m_outenpear.push_back ('%'); m_outenpear.push_back (toHex (*pinpear >> 4)); m_outenpear.push_back (toHex (*pinpear % 16)); } } } return 0; } int decodeTransfer (std::vector < char >&indepear) { m_indepear = indepear; std::vector < char >::iterator pinpear = m_indepear.begin (); char tmpinpear = 0;; char outpear = 0x00; for (; pinpear != m_indepear.end (); pinpear++) { tmpinpear = *pinpear; if (((0x20 < tmpinpear) && (tmpinpear < 0x5b) && (tmpinpear != '%')) || ((0x60 < tmpinpear) && (tmpinpear < 0x7b)) || ((0x2f < tmpinpear) && (tmpinpear < 0x3a))) { m_outdepear.push_back (*pinpear); } else { /** * (((0x08 < tmpinpear) && (tmpinpear < 0x0e)) || (tmpinpear == 0x20)) -->'+' *' +' --> 0x20 * it is a limit ; the correct is what? i don't know */ if ('+' == tmpinpear) { m_outdepear.push_back (0x20); } else { if ('%' == tmpinpear) { tmpinpear = *(++pinpear); outpear = (tmpinpear - 0x30) << 4; tmpinpear = *(++pinpear); if (tmpinpear > 0x40) tmpinpear = tmpinpear - 0x37; else tmpinpear = tmpinpear - 0x30; outpear += tmpinpear; m_outdepear.push_back (outpear); } } } } return 0; } int encodein () { for (int i = 0; (i < m_inenpear.size ()) && (i < 1000); i++) { std::cout << m_inenpear[i]; } std::cout << std::endl; return 0; } int encodeout () { for (int i = 0; (i < m_outenpear.size ()) && (i < 1000); i++) { std::cout << m_outenpear[i]; } std::cout << std::endl; return 0; } int decodein () { for (int i = 0; (i < m_indepear.size ()) && (i < 1000); i++) { std::cout << m_indepear[i]; } std::cout << std::endl; return 0; } int decodeout () { for (int i = 0; (i < m_outdepear.size ()) && (i < 1000); i++) { std::cout << m_outdepear[i]; } std::cout << std::endl; return 0; } std::vector < char >&getoutpear () { return m_outenpear; } }; |
|
|
|
|
|
|
|
第 99 帖 | |
|
|
标题: 偶也来一个:搜索体积较大的文件,自动备份 代码:
|
|
|
|
|
|
|
|
第 100 帖 | |
|
|
统计ip登陆次数
#!/bin/sh I=0 while [ $I -lt 255 ] do I=$[ $I+1 ] Count=0 IP=192.168.0.$I while read IPA M do if [ $IPA = $IP ] then Count=$[ $Count+1 ] fi done<log.txt if [ $Count -gt 0 ] then echo "$IP $Count" fi done log .txt 文件格式 192.168.0.1 dfgsdfgsd ......... ......
__________________
wangwang——(往往) 修炼中 ........................................................................ |
|
|
|
|
|
|
|
第 101 帖 | |
|
|
标题: mpc转mp3 感谢liquid_zigong兄
方法1: 代码:
代码:
mppdec可是大名鼎鼎的MusePack(mpc)音频格式的Linux版播放器。它也可以用来把MPC文件转化成WAV。不过它似乎不能把输出重定向到标准输出,所以得用命令管道才能实现即时(on-the-fly)编码。而且输出名字必须有.wav后缀,不然有问题 MPC的音质和效率可比MP3高多了,它有XMMS的plugin,可自行安装。 它的编码器叫mppenc
__________________
深邃的技术不仅表现在敏捷的思维和高超的本领,还有过人的修养。 |
|
|
|
|
|
|
|
第 102 帖 | |
|
|
这些脚本很好,可以我在公司不能天天上网,只能传文件。
要是有那位大虾把这些脚步都打包,就好了。
__________________
programming |
|
|
|
|
|
|
|
第 103 帖 | |
|
|
计算networkid netmask broadcast
For Expamle: ./net.sh 192.168.1.0 255.255.252.0 Network number: 192.168.0.0 Broadcast address: 192.168.3.255 Netmask bits: 22 #!/bin/bash if [ $# -ne 2 ];then echo "Usage:./net.sh ipaddress netmask" exit fi ip=(${1//[![:digit:]]/ }) echo "$ip" mask=(${2//[![:digit:]]/ }) for i in ${mask[*]} do j=7 tag=1 while [ $j -ge 0 ] do k=$((2**$j)) if [ $(( $i & $k )) -eq $k ]; then if [ $tag -eq 1 ]; then (( n += 1 )) else echo -e "\n$2 is a bad netamsk with holes\n" exit fi else tag=0 fi (( j -= 1 )) done done for i in 0 1 2 3 do a=$a${a:+.}$((${ip[i]} & ${mask[i]})) b=$b${b:+.}$((${ip[i]} | (${mask[i]} ^ 255))) done echo Network number: $a echo Broadcast address: $b echo Netmask bits: $n
__________________
hard hard study good good day |
|
|
|
|
|
|
|
第 104 帖 | |
|
|
自动ftp脚本: 可以用来更新named.root 文件.
ftp -i -n ftp.rs.internic.net <<AUTO user anonymous abc #anonymous 是用户名 abc 是密码 lcd /var/named cd domain hash get named.root AUTO |
|
|
|
|
|
|
|
第 105 帖 | |
|
|
标题: sussh:一个使su能forward X的脚本。
__________________
15" C2D MBP. 有简单的,不用复杂的!看到复杂的,尽量简单化! Unix/Linux Philosophy: Be small! Be concentrated! One program does one thing and do it perfectly! ∞ years - 宇宙中最后的物质 Proton heat death. 之后,宇宙将以纯能量的形式永远存在。。。一切皆空 |
|
|
|
|
|