I have been writing a html interface for displaying tables, pie charts, data etc.
The Perl script that generates the data and the tables can be called by a single command at the terminal and I want to have a button in the html that will call this. I don’t really need any feedback from the Perl script once it’s going, although if it could ping back a “everything went better than expected”, that would be nice.
Currently however, every time I click the submit I get asked to open or save the Perl script and after a day of googling I cant fix it and would appreciate some advice.
I am new to html and js, but this is what I have so far:
<form action="scripts/do_processing.pl" method="get">
<table>
<td>Select input file: (must be fasta format)</td>
<td>
<input type="file" name="first_name" value="" maxlength="100" />
</td>
</tr>
<br>
<tr>
<tr><td>Binning:</td>
<td>
<input type="radio" name="bin_method" value="blastn" /> Blastn
<input type="radio" name="bin_method" value="blastx" /> Blastx
<input type="radio" name="bin_method" value="megan" /> Megan
</td>
</tr>
</table>
<br><br>
<input TYPE=IMAGE
SRC="images/go_button-green.jpg"
HEIGHT=100 WIDTH=auto
ALT="Go!" BORDER=0
NAME="go"
>
</td>
</tr>
</form><br>
It is only to be ran locally, I have no intentions to have it accessible to the outside world and am therefore avoiding CGI and Apache-esque solutions which I think are unnecessary. Links are all good as it tries to open the file each time.
Note: The input is not relevant at the moment, as the perl script I’m currently trying to call is just a “Hello World!”
For what you are doing, you need to use a web server unfortunately.
In your case, when you open the HTML file locally, when you click on the form, your browser looks at the action and goes to that “address” based on where your web page is, since you are local, your webpage is a file:// url, so it basically goes to your perl file (which is what you want) except that the browser itself simply requests the file from your filesystem and does not know what to do with it, the filesystem DOES NOT run your perl script, it simply serves the file. So it’s only posible response is to offer you to download it.
In the context of a web service, when you tell the server “go to this perl file” and assuming the web server is correctly configured, the web server notices that the .pl is a special file and it has to run it, so it does, and then grabs its output and sends it to your browser. Which is what you want to do.
Hope this helps.