Sorry for not provided the complete info.
I just want to explain the background of my script below...
My basic Requirement is to create the web-based Runbook for the user using the CGI-Perl.
1.Configured the Apache and Perl on my unix system -->woring fine.
2.I have written the three CGI scripts.
a)First script(cgi1.cgi) show the webpage which ask for the user input using textbox and radio buttons --> working fine.
After user providing the input data(Storage name and Type of Request),he will click on the submit button.
b)Second Script(cgi2.cgi) capture the input which was provided by the user in cgi1.cgi script and run the remote command on the storage box and display the output on the next webpage and display the "confirm" button at the end of webpage --> working fine.
When user reviewed the output data on the wepage and click on "confirm" to save the output data to one file in the web server --> Not working.
3) Third script(cgi3.cgi),just display the info on the webpage with info "Runbook created successfully and saved in file" --> working.
I m using the Onclick with subroute in my second script(cgi2.cgi) to save data in File.but it's not working.
I have attached my script for more info.Please help..
----
#!/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;ou
+r $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), "<br><br>",
"You Enter the Choice: " , $obj->b($choice), "<br><br>",
"You Enter the Filer/Volume list is :", $obj->h4($list),"<br><br>";
@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<br>",
print
"$eachrelation<br>",
}
}
}
}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_pat
+h=>"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<br>",
print
"$eachrelation<br>",
}
}
}
}
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);
}
|