Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: CGI-Perl: how to save data to file

by Discipulus (Canon)
on Oct 23, 2014 at 09:08 UTC ( [id://1104751]=note: print w/replies, xml ) Need Help??


in reply to CGI-Perl: how to save data to file

hello srinuperl,
can I tell you that your question is very poor detailed?
What have you tried? which part does not run as you expect?

L*
PS i have moved your question from Discussion to Seekers of Perl Wisdom, as i messaged to you.
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: CGI-Perl: how to save data to file
by srinuperl (Initiate) on Oct 24, 2014 at 18:00 UTC

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

      I'm sorry, but "but it's not working" is not a good error description.

      Please tell us how it fails to work.

      Does your script get called?

      Does your script fail to create the file?

      Does your script exit with an error? If so, what is the error message?

      Does your script store the wrong data?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1104751]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-20 01:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found