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); }

In reply to Re^2: CGI-Perl: how to save data to file by srinuperl
in thread CGI-Perl: how to save data to file by srinuperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.