Open Chinstrap

April 7, 2008

Configuring Eclipse EPIC on Ubuntu

Filed under: Apache, Linux, Perl, Ubuntu, Web Development — t-roy @ 7:14 pm

E-P-I-C is a good Perl plugin for Eclipse (Version: 3.3.2 Build id: M20080221-1800) . You can use EPIC to develop perl scripts and Perl CGI (Common Gateway Interface) scripts. To install the plugin you can use the update site located here:

http://e-p-i-c.sf.net/updates

Creating a Perl project is very straight forward: File>New>Perl Project

New Perl Project

 

 

 

I will focus on configuring a CGI script since the regular Perl scripts are fairly straight forward . First we need to create our script by right-clicking on the project folder and selecting New>Perl File:

New Perl File

 

 

 

Name the file test.cgi and copy and paste the following simple CGI script:

#! /usr/bin/perl

print “Content-type: text/plain \n\n”;
print “Hello World!\n”;
print “Script Name: $ENV{SCRIPT_NAME}”;

Save the file (CTRL-s) and now we are ready to set up the Perl CGI Configuration. But before we do that it is important to record the full path of the Perl Eclipse project and remember the name of the script you want to run. Eclipse usually creates a workspace directory in your home directory unless you specify otherwise. In my case my workspace is located in:

/home/scottt/workspace

Therefore my Perl project is located in:

/home/scottt/workspace/perlwebscripts/

And the path to my CGI script is:

/home/scottt/workspace/perlwebscripts/test.cgi

Now that we have this information we can configure our CGI script. Right-click on the project folder or any file in the project and select Run As>Open Run Dialog…. :

Perl CGI Configuration

 

 

 

 

In the Main tab you need to select the project folder name in my case it would be perlwebscripts. The Web Server tab (shown above) contains the following information:

  • HTML Root Directory: /home/scottt/workspace/perlwebscripts
  • HTML Startup File: /home/scottt/workspace/perlwebscripts/test.cgi
  • CGI Root Directory: /home/scottt/workspace/perlwebscripts

All paths are related to your Eclipse CGI project. The final thing to configure is the browser tab which is where the result of the CGI Script is displayed. I used the Firefox adapter. I was not able to get the Internal Perl Browser to work. The Firefox browser works fine but it is a bit of a pain to Alt-Tab between Eclipse and Firefox while you are developing. Hit apply once the configuration is finished and then you can click Run As. Here is a screenshot of the test.cgi script :

CGI Test Script

 

 

 

 

EPIC also provides a good user guide which you can download from here.

Troy

Blog at WordPress.com.