0

I am a newbie in Bioinformatics but I know perl scripting. I've written few scripts for parsing pdb files(protein crystal structure files). Now I want to run these in a web server. I have apache2 installed in my ubuntu. I have read something about the CGI and is in /usr/lib/cgi-bin/ in local web server. I need to have all my perl scripts in that directory. These scripts takes input from command line ex: perl contacts.pl pdbFile.pdb.

Now how can I run these scripts inside a perl CGI script so that the CGI script throws html page on the fly and asks for user input (this includes PHP I guess). At the end I should have a html page able to run my perl script (contacts.pl) upon user input.

If its not possible to run my perl script in html web page, what is the other alternative?

Any help will be greatly appreciated.

Andy Lester
  • 91,102
  • 13
  • 100
  • 152
Bionerd
  • 21
  • 1
  • 6
  • No PHP is required here and using PERL for web development has been covered in hundreds of online tutorials and dozens upon dozens of books. – Jay Blanchard Mar 24 '15 at 12:58
  • Isn't it possible to run my perl code in a CGI perl script? – Bionerd Mar 24 '15 at 13:03
  • Of course it is. You just need to do a little reading to see how all of the pieces fit together. – Jay Blanchard Mar 24 '15 at 13:04
  • I have goggled for this..but I found many of those..Can you please provide me an address where I can easily understand, as I came from biology I am wondering which one to choose that best serves me – Bionerd Mar 24 '15 at 13:07
  • I cannot tell you which will suit you best, just give you a [starting point](http://www.perlmonks.org/?node_id=920554) – Jay Blanchard Mar 24 '15 at 13:09
  • 1
    You have to read about HTML forms, Apache CGI configuration and generating HTML pages with perl (perhaps use CGI.pm). You need one HTML page that has a `
    ` element, you collect user input here. When user clicks submit, the web browser sends input data to web server. A CGI enabled server, runs the script specified in form's `action` attribute and passes this data to it. The script does what you want with the inputs, and generates a HTTP response that is sent to the browser as response to form submission. These are steps involved in dynamic content generation using CGI.
    – pii_ke Mar 24 '15 at 16:59
  • @pii_ke thank you.. [http://stackoverflow.com/questions/11817809/steps-in-order-to-pass-data-from-html-form-to-perl-script] and some other gave me an idea. But when I run the uploading the file, the browser is directly showing the perl script as a text instead of the result of the file uploaded. I think passing the uploaded file to the perl script went wrong. Can you give me a hint to pass the file to cgi script as an array. – Bionerd Mar 25 '15 at 19:00
  • Perhaps you have not properly configured Apache to process your CGI program (http://httpd.apache.org/docs/2.2/howto/cgi.html#configuring), or your CGI script is not marked executable (`chmod +x scriptfile.pl` ). – pii_ke Mar 26 '15 at 00:19

2 Answers2

2

I don't think I'd run everything through CGI. If I were you, I'd look at using a perl web framework to handle generating the webpages and (presumably) uploading files, and then call your existing code to parse the pdb files and get whatever you're interested in.

Some popular frameworks:

As for running the webserver, they should have deployment guides with instructions for apache. Or use another webserver like starman that can run perl webapps easily.

nfg
  • 31
  • 3
1

For a start you can get basic ideas from below links :

Perl/CGI script with Apache2

CGI script calling a perl script

First Perl CGI script

serenesat
  • 4,611
  • 10
  • 37
  • 53