proxy代理   soft软件   IT 业界特快   norton 诺顿病毒库   代理列表   search FTP搜索   whois IP地理位置   blog 追求完美  
money理财   life生活   RSS聚合门户   firefox WEB浏览器   免费域名   typeset 假古文   AntiVirus 反病毒   ipcn 站点导航  

« KVM(Keyboard Video Mouse) 远程机房控制和管理解决方案 | Main | ipcn.org / ipchina.org - alexa / google / baidu »

September 10, 2004

脚本 bash perl

版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明。
https://windtear.net/archives/2004/09/10/000484.html

上午写了两个脚本
晚上进行了完善

----->   bash
$? 表示返回值
cat << USAGE 注释效果很好
usage () { } 子函数
[[ $1 = "-h" || $1 = "--help" || $1 = "-v" || $1 = "--version" ]] && usage
[[ $# -ne 3 ]] && usage
参数 $1 从1开始记数
if echo $string | grep -q -c ^pattern; then ... else ... fi
if [ $? -eq 0]; then ...
数字比较用 -eq -ne ...  字符串直接 [ "$a" = "$b" ]
echo cat 打印

----->   perl
参数从$ARGV[0]开始记数
@ARGV 直接与数字比较就是数字个数
if (@ARGV != 2) { usage(); }
sub usage { }  如果要参数 可以  sub usage($) $$ $$$ ... 然后 @_ 取
变量要加 $ % @ 等  (而 bash 直接赋值 调用才 $VAR)
每一行还要有分号结尾
open(IN, "file") || die "cant open file";
print 打印
while for foreach 等循环
模式匹配 $str =~ /abc/i;  .*?(\d+) $1 为匹配结果等

----->
昨天写的两个脚本 小工具开会
处理参数的 perl 模组 Getopt::Long
bash scripts sample - for loop v.s. xargs
代理自动封禁 squid autodeny.pl
www 的自动封禁 80autodeny.pl
passchsquid.sh -- Password Change For Squid Auth
newftpuser.sh for proftpd

 
本blog WWW

Posted by windtear at September 10, 2004 9:08 PM

本站使用中的任何问题,请与 windtear @ windtear.net 联系
Copyright© 1999-2024 Windtear. All rights reserved.