微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

perl小程序

#!/usr/bin/perl $count=0; while($count < 100){ print "\n\n\n\n"; print "please input password: \n"; $count+=2; #print "$count \n"; $ftp=1; $news=2; $zhaoyun=3; $postfix=4; $oracle=5; $ntp=6; $line=<STDIN>; if($line eq "$ftp\n"){   print "ftp \n";   $a=`cat /etc/passwd |grep ftp | sed -n 1p`;   print $a;}else{   if($line eq "$news\n"){      $a=`cat /etc/passwd |grep news | head -n 1`;      print $a;     print "news \n";}else{     if($line eq "$zhaoyun\n"){      $a=`cat /etc/passwd |grep zhaoyun | head -n 1`;      print $a;       print "zhaoyun \n";}else{       if($line eq "$postfix\n"){         $a=`cat /etc/passwd |grep postfix | head -n 1`;         print $a;         print "postfix \n";}else{         if($line eq "$oracle\n"){          $a=`cat /etc/passwd |grep oracle | head -n 1`;           print $a;           print "oracle \n";             }else{           if($line eq "quit\n"){             exit;}else{             if($line eq "$ntp\n"){               $a=`cat /etc/passwd |grep ntp | head -n 1`;               print $a;               print "ntp \n";}else{               print "password input error! \n";              }             }           }         }       }      }    }    } 实现输入对应的数字,打印相应的内容。 [root@bogon perl]# ./test please input password: 1 ftp ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin please input password: 2 news:x:9:13:news:/etc/news: news please input password: 3 zhaoyun:x:500:501::/home/zhaoyun:/bin/bash zhaoyun please input password: fd password input error! please input password: quit [root@bogon perl]#

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐