Linuxsky
中国青基会
您当前的所在的位置是:主页>自由文档>程序开发> 文章页面

perl的switch

去论坛讨论 来源:未知 作者:admin 发布时间:2010-06-03

 

#!/usr/bin/perl -w
use strict;

sub useage(){
print "用法:$0 1|2|3|4 r|s|rs\n";
}
sub jboss_oprate(){
my ($host,$oprate)=@_;
system("ssh","$host",". /etc/profile;$oprate");
}


print "本程序用于重启rs1 rs2 rs3 rs4中的jboss服务器\n";
useage(),exit if $#ARGV != 1;
my $host=shift;
my $oprate=shift;
SWITCH: {
$host == 1 and $host="rs1",last;
$host == 2 and $host="rs2",last;
$host == 3 and $host="rs3",last;
$host == 4 and $host="rs4",last;
useage(),exit;
}
SWITCH: {
$oprate eq "r" and $oprate = "jbr",last;
$oprate eq "s" and $oprate = "jbs",last;
$oprate eq "rs" and $oprate = "jbrestart",last;
useage(),exit;
}
print "现在对服务器$host进行$oprate操作:\n";
&jboss_oprate($host,$oprate);
print "程序运行完毕\n";

免费注册 | 网站地图 | RSS订阅 | 友情链接 | 论坛交流 | 用户搏客 | 返回顶端

站内资料部分由本人收集整理,所有文章版权均系原作者和出版者所有,如涉版权问题,恳请来信告知!

本站原创作品除特别声明外皆以创作共用协议发布