---- #!/usr/bin/perl use strict; use warnings; use CGI; use Net::OpenSSH; our $ssh;our $KeyFile; my $obj;our $list;our @splitlist;my $eachline;our $date;our @splitdate;our $choice;our $DrType;our @cmdout;our $command;our $user;our $host;our @list1;our @uptime;our $eachhost;our @error;our $eachrelation;our $eachvol;our @splitline;our $hostname;our $volpath;our $count;our @outarray;our @array; $date=`date`; @splitdate=split(" ",$date); $obj=new CGI; print $obj->header, $obj->start_html(-title=>'Output Of the Runbook'), $obj->center($obj->h2('RunBook Output')), $obj->start_form( -method=>'POST', -action=>'http://192.xxx.xxx.xxx/scripts/CreateAtt.cgi' ); $DrType=$obj->param('radio'), $choice=$obj->param('radio1'), $list=$obj->param('FilerList'), print "You enter DR Type: ", $obj->b($DrType), "

", "You Enter the Choice: " , $obj->b($choice), "

", "You Enter the Filer/Volume list is :", $obj->h4($list),"

"; @list1=split(/\s+/,$list); $count=0; if($choice eq "Filers") { foreach $eachhost(@list1) { chomp($eachhost), $ssh=Net::OpenSSH->new("$eachhost",user=>"sri",key_path=>"XXXX"); @uptime=$ssh->capture("snapmirror status"); if(!@uptime) { print $ssh->error and die "On $eachhost cannot run the command"; }else{ foreach $eachrelation(@uptime) { next if($eachrelation=~m/^Snapmirror/); next if($eachrelation=~m/^Source/); chomp($eachrelation), $array[$count++]="$eachrelation
", print "$eachrelation
", } } } }else{ foreach $eachvol(@list1) { chomp($eachvol), @splitline=split(":",$eachvol), $hostname=$splitline[0],$volpath=$splitline[1], chomp($hostname),chomp($volpath), $ssh=Net::OpenSSH->new("$hostname",user=>"sri",key_path=>"XXXX"); @uptime=$ssh->capture("snapmirror status $volpath"); if(!@uptime) { print $ssh->error and die "On $eachhost cannot run the command"; }else{ foreach $eachrelation(@uptime) { next if($eachrelation=~m/^Snapmirror/); next if($eachrelation=~m/^Source/); chomp($eachrelation), $array[$count++]="$eachrelation
", print "$eachrelation
", } } } } print $obj->br(), $obj->br(), #$obj->center($obj->button(-name=>'Confirm',-value=>'Confirm',-onClick=>"copy(@array)")), $obj->center($obj->submit(-name=>'Confirm',-value=>'Confirm',-onClick=>"copy(@array)")); #$obj->end_form(), $obj->end_html(); sub copy { @outarray=@_; open(FH,">/home/srinu/scripts/textfile") or die "cannot write to file"; print FH @outarray; close(FH); }