How to call a perl cgi script from another perl cgi script - html

I have a html form ... While submitting that form, I am calling one Perl CGI Script, that will save the data in MYSQL database.
After saving the data in databse, i want to reopen the same page with all empty fields in form, means i want too reload the same form again.
How can i achieve this? or what should i call in my script so that i can come back to same form again.
Remember i am generating the forms using template and perl script..
Thanks in advance

You can redirect using HTML's meta refresh or by using JavaScript's window.location object. Have the CGI script output any of those.
Another way is to have the CGI script output a redirect header. You can use CGI's redirect method for this, or output it manually.

Is this second program really a CGI program? I mean does it accept parameters from a HTTP request and return it's results in an HTTP response?
If that's the case then you can call it using libraries from the LWP CPAN distribution.
If your second program is actually just a command program then you can call it using system.

Related

How to pass arguments at runtime which can be picked by html code

I want a parameter in html code to be dynamic which is passed while the code. For eg if I run eg.html?link=https://google.com then the html code should be able to parse google.com and be able to open it. If I run eg.html?link=https://gmail.com, then gmail should open.
HTML alone cannot do that. In order to dynamically change the content of the HTML file, you will need some server-side processing using a language such as PHP, Python, or Node.js.

read input from html forms, execute local program,output results

I have a question that will help me understand how stuff works and investigate feasibility of a bigger plan I have in mind.
Simply given - lets assume that all things run locally - I am wondering if it is possible to:
create an html page with a form that will prompt the user to enter
the local path of an input file inputFile.dat
this input file will be fed to a c++ exe program that expects it for input
the c++ exe file will run (this exe file depends on libraries etc but lets assume all are local here)
... and will output the result on screen
It sounds simple, but is it?
Many thanks folks!
Yes, this is definitely possible, if you want to use PHP or some other scripting language.
Create a form on your web page
Add the directory of the program
Add the directory of the data
When submitted, use the PHP (or other language) exec function (docs) to execute the program, with the supplied data as argument
The exec function returns output from the program.
Display the output as wished on your page.
Good luck!

Process perl script On POST method in Django

I am newbie ,am trying to process perl script on submit button in HTML in Django framework.I will try to be clean and clear what i wann do, Apologies for my English language.
I have build simple registration website using Django framework.In that instead of using Django auth, i want to call perl script and process the new user registration form.
I have written code for simple new user registration form and perl script which takes data from HTML and splits that data and send it to back-end for further process.I successfully accomplished this task using CGI server.
This process i want to call in Django framework .How can I do this .I tried to do it with subprocess but Am not getting solution for this .
Thank You
Pervez
run your perl script as cgi, post registration form to the script
<form action="your-perl-script.cgi" method="POST">
...
</form>
I don't quite understand why you would want to do that, but you can run the perl script as a system command, like:
import commands
commands.getstatusoutput('perl /path/to/script.pl arguments')

Save a file after a perl script runs on a web page

I have a web page that will be used to create KML Files with a perl script.I want the user to add some data to a form that will be used in my perl script. When the form is submitted it will run the script, create a kml file, then prompt the user to save the file. The only part I am not sure about is how to have the user save the file after the script has created the KML. Do I have the perl script prompt the download or use something on the HTML page prompt the download. I am not sure the best way to do this.
If you have a link or a form for telling the server to build the KML then just generate the KML normally and send it back to the browser with some extra HTTP headers. The headers you want are:
Content-disposition set to attachment;filename=whatever.kml where "whatever.kml" is what you want the file to be called.
Content-type set to application/vnd.google-earth.kml+xml.
The Content-disposition should tell the browser to download the KML instead of trying to handle it.
So the Perl script will be prompting the browser to prompt the download.
Assuming the contents of the kml file are in $kml then you'd want to do something like:
use CGI;
my $cgi = new CGI;
print $cgi->header('-Content-disposition' => 'attachment;filename=kml.xml',
'-Content-type' => 'application/vnd.google-earth.kml+xml');
print $kml;

How To load data that are accessed from database to html form

I am trying to access data from table with GetString() method and that data is stored in some variable then it must be loaded to html form when i am click the submit button. How to it? Please help me......
This question is too general.
In order to access the database you need a web server running server-side code in a language such as ASP.NET, Java, PHP, etc. The server code would be responsible for using a "GetString()" method to read the table and populate data in the form (or even better, return it to an MVC View or to JavaScript via AJAX to load it onto the HTML form).