CGI Scripts on JustHost Hosting | Make Them Work

This guide explains how to get CGI scripts working with your JustHost hosting account.
Getting Your Script Working
You’d think they would just work off right away.. but there are a few things you have to do:
  • Make sure that your script begins with the line: #!/usr/bin/perl -w
  • Then enter any of the use statements that your script relies on
  • Under the use statements enter the following line: print “Content-type: text/html\n\n”;
  • Under that line you enter the main part of your script.
  • Upload your script to the cgi-bin directory of your web server.
  • Change the permissions on the script to 755. This is VERY important, JustHost servers require the permissions of CGI files to be set to 755. You can set this from any ftp client, or form inside the File Manager section of your JustHost cPanel.
  • That’s it! Your script should now run if you point your browser to the address (probably http://YOURDOMAIN.com/cgi-bin/YOURSCRIPT.cgi)

Professional Hosting fro Just Host
Some Additional Notes
You can install perl modules from inside cPanel (in the Perl Modules section.) To make sure that your script picks up all of these installed modules, you must add the following chunk of code immediately under the first line of your script:

BEGIN {
my $base_module_dir = (-d ‘/home/YOURUSERNAME/perl’ ? ‘/home/YOURUSERNAME/perl’ : ( getpwuid(mce_markergt;) )[7] . ‘/perl/’);
unshift @INC, map { $base_module_dir . $_ } @INC;
}
Note that YOURUSERNAME must be changed to the username that you login to your JustHost cPanel with.
A Sample CGI Script That Runs on JustHost Hosting
#!/usr/bin/perl -w
BEGIN {
my $base_module_dir = (-d ‘/home/USERNAME77/perl’ ? ‘/home/USERNAME77/perl’ : ( getpwuid($>) )[7] . ‘/perl/’);
unshift @INC, map { $base_module_dir . $_ } @INC;
}
use strict;
print “Content-type: text/html\n\n”;
print “This script is working!”;
Make sure that after you upload the file to your hosting space you set the permission to 755!