Go4Expert (http://www.go4expert.com/)
-   Web Development (http://www.go4expert.com/articles/web-development/)
-   -   Installing CGI-Scripts (http://www.go4expert.com/articles/installing-cgi-scripts-t71/)

vishal sharma 28Jul2004 09:40

Installing CGI-Scripts
For many new webmaster this is probably one of the most daunting tasks they'll need to do. Mainly because you're not used to the UNIX environment, but also because you have to edit some perl scripts to make the script work. Here are the basic things you need to install CGI-Scripts.

You need a web host that gives you a cgi-bin, most free hosting companies won't give you a cgi-bin because of security reasons. If you're on a free web host and you want to add things like a guestbook or message boards, I would suggest you use a service like www.bravenet.com they have codes that you just cut and paste. Good thing, it's easy, bad thing, it has advertising and it generally makes your page look a little less professional.

You'll need the script itself. You can download almost any cgi-script for free at www.cgi-resources.com this is where I go to get any scripts that I'll need for the websites I write.

You'll need a plain text editing program. If you're in a windows operating system Notepad would be fine to edit perl / cgi scripts. (Don't use Word, Wordpad or any other "rich text" type program, it will screw up the script).

You'll need an ftp program, this is a program that will upload your page to your server. I like WS_FTP Pro, you an use the lite version of this program, which is free, but this pro version offers more features and easier to use I think.

Okay, so that's what you'll need, now here is the important things you'll need to know about installing the scripts:

Always read the included installation instructions. All scripts come with a readme.txt file or some form of installation instructions. Read these carefully, because they'll tell you how and what you need to do for this script.

Knowing the perl path for your server. In all cgi scripts the script itself will need to know where the perl kernel is. In most cases the perl path is /usr/bin/perl and most people that write scripts will point it here, contact your web host if you're unsure of where the path to your perl kernel is

Make sure to upload the .cgi files to the cgi-bin on your server. Almost all the servers I've been on makes you upload your scripts to a separate folder called the cgi-bin. If you upload your script elsewhere it just won't work (note, on some servers they do allow you to put the cgi-scripts in any directory, but it's been my experience that most have the separate cgi-bin).

When uploading CGI, make sure that you upload it in ASCII, not BINARY, if you upload it in Binary the script will not work. Binary is for photos and regular pages, but for scripts you'll need to upload it in ASCII format.

Know the root to your cgi-bin and also the public_html files. Most of the times the path will look like /home/username/domain name/public_html and the root to your cgi-bin will look like /home/username/domain name/cgi-bin - Once again, you'll need to contact your web host if you're unsure. Also, some scripts will point to the cgi script by having the url and not the root, pay attention to what the script asks, because sometimes it will be the url where the script is located, like, http://www.yourdomain.com/cgi-bin/scriptname.cgi

Knowing your sendmail path. This is for scripts that will allow users to email or perhaps if the program emails you if someone posts messages etc. The send mail path is usually /usr/lib/sendmail once again, if you don't know contact your web host or check their FAQ, they usually give this information there.

Knowing how to chmod or set permissions to files and directories. All the scripts you download will tell you to set permissions to your scripts and files, you must do this! If they say to set the permission to a certain number, you must do so! If you don't, the script won't work! In the different ftp programs there are different ways to set permissions, usually most will have where you can right click on the file and there will be a permissions button or a chmod button and then you can set the permissions that way.

Contact your web host if you have trouble...always remember that you're paying for a service and most places offer technical support, don't be too shy to ask for help, that's what technical support is there for and especially if you're paying for the service you should use the service as much as you can!

These are the basics you need to know, each script is different, some programmers really go out of their way to make the script easy to install, some programmers write great scripts but give lousy instructions, so, just try out some scripts, don't be scared of them, and don't give up on them, because the first few times, you'll almost always get errors, trust me, I should know!

One other thing, I found with my own webhosting company that they weren't that willing to give cgi help, I think that's sort of lame to tell you the truth. A company that offers services should be knowledgeable on such topics, but you often find tech support usually knows less than you and that you're on your own most of the times.

I've installed lots of scripts now and there are a few that I'll use over and over again because they're just so easy to install and really work great. If you want some help in this area I can point you to the easiest to install cgi-scripts, just tell me what your looking for or I'll write a tutorial on what scripts to use. Have fun, don't get frustrated, and don't give up, you'll get the hang of the cgi-scripts soon enough :o) If not, email me and I'll try and help out.

alok 28Jul2004 12:17

Re: Webmasters--Installing CGI-Scripts
sorry to Disturb you in this matter :d
but i think the CGI is now obesolute technology,every buddy is going after new technology like JSP and ASp which more Fast and efficient.
sorry ,but that truth,it that hurt i am sorry.

shabbir 28Jul2004 13:01

Re: Webmasters--Installing CGI-Scripts
Sorry Alok but cgi is not at all obsolete and lots of technology still uses cgi. Perl is the most exciting language for cgi and still in development phase its use is increasing day by day.

Shabbir Bhimani

alok 28Jul2004 13:48

Re: Webmasters--Installing CGI-Scripts
may be you are rite
but with all due respect,no buddy want to use it when same functionality is provided by more powerful and easy scripting lanaguge like ASP ,PHP( which is upgrade of perl) and JSP.
may be it on developmental stage,but why to develop a thing which already obesolute

shabbir 28Jul2004 18:52

Re: Webmasters--Installing CGI-Scripts
Alok, now I think you are not very much unknown to web technology.

PHP( which is upgrade of perl)
First PHP and perl are nowhere related

JSP can be considered as an easy way to use Java on web.

Now if you say
but with all due respect,no buddy want to use it when same functionality is provided by more powerful and easy scripting lanaguge like ASP ,PHP( which is upgrade of perl) and JSP.

so now the question comes why there are 3 scripting languages and not one say APJ(ASP,PHP,JSP). All can provide same functionality and to be honest all cannot have the same ranks if we define them with no1, no2, no3.

Now if its on development and you are critising perl then this means that perl is famous and not obsolete.
Windows is attacked by virus but not linux. What does it mean that non windows lovers want to give trouble to win guys but they think to keep linux clean but microsoft can develop virused for linux if they want but knows that Linux is nowhere near win and so doesnot need it.

Alok if this hurts please dont mind.

Shabbir Bhimani

alok 29Jul2004 18:50

Re: Webmasters--Installing CGI-Scripts
YEah i am new to webtechnology,the only weblanaguge i know is HTML :D
Basically i quoted wrong that PHP is Upgrade of perl. actaully they are syntacally same.
and abotu perl really my knowledge is zero do you have any good article that support that perl is lanaguage of future.
basically Web is not my line i am vc++ Programmer and i work as System programmer in small company and trust my word my level is that of beginner

shabbir 22Jan2007 08:05

Re: Webmasters--Installing CGI-Scripts
Benjamin78, your hosting url is self promotion without the context of the article and is deleted.

rapwaydown 8Dec2007 05:54

Re: Webmasters--Installing CGI-Scripts
wow, im new to web technology, still dont know HTML very good
but getting there

ashleycameron 9May2008 06:08

Re: Webmasters--Installing CGI-Scripts
Hi, This is awesome article. Its very interesting and informative, Where you read this topic. Its really great work. Try to post these kind of article often... Best of Luck.

Jenniferlinn 26Dec2008 13:43

Re: Webmasters--Installing CGI-Scripts
Hello vishal

Thanks for posting such a useful article here, It clears most of my doubts about the topic

Lizapotter 25Feb2009 11:59

Re: Webmasters--Installing CGI-Scripts
Tips while using CGI:

1. Beware the eval statement

Languages like PERL and the Bourne shell provide an eval command which allow you to construct a string and have the interpreter execute that string. This can be very dangerous. Observe the following statement in the Bourne shell:

eval `echo $QUERY_STRING | awk 'BEGIN{RS="&"} {printf "QS_%s\n",$1}' `

This clever little snippet takes the query string, and convents it into a set of variable set commands. Unfortunately, this script can be attacked by sending it a query string which starts with a ;.

2. Do not trust the client to do anything

A well-behaved client will escape any characters which have special meaning to the Bourne shell in a query string and thus avoid problems with your script misinterpreting the characters. A mischevious client may use special characters to confuse your script and gain unauthorized access.

3. Be careful with popen and system.

If you use any data from the client to construct a command line for a call to popen() or system(), be sure to place backslashes before any characters that have special meaning to the Bourne shell before calling the function. This can be achieved easily with a short C function.

4. Turn off server-side includes

If your server is unfortunate enough to support server-side includes, turn them off for your script directories. The server-side includes can be abused by clients which prey on scripts which directly output things they have been sent.

Apostile 1Jun2009 13:25

Re: Webmasters--Installing CGI-Scripts
netCHARTING enables your web site to display massive amounts of dynamically generated data quickly and easily through a visual interface. Built with 100% managed code using C# and provided with extensive samples in both VB.NET and C#, this high performance charting control also contains a feature rich data access and aggregation system with calculation support. We continue to add value and functionality (such as the gauge and dial chart added in 2.5, the geographic map chart and vector chart in 4.0, AJAX scroll / zoom in 5.0, organizational charts in 5.1 and digital dashboards charts in 5.2) to .netCHARTING with no separate add-on purchases required. See what's new or download a fully functional, free, developer version and start charting today!

wilomr11st 8Aug2012 06:17

Re: Webmasters--Installing CGI-Scripts
Sorry Alok but cgi is not at all obsolete and lots of technology still uses cgi. Perl is the most exciting language for cgi and still in development phase its use is increasing day by day.

All times are GMT +5.5. The time now is 01:51.