473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Need help on Running a CGI program

I just started to learn CGI as I have some Basic knowledge in perl.
Iam Just trying to run a simple Hello world program and i face some problems
let me know ifthe procedure I followed is correct.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -wT
  2. print "Content-type: text/html\n\n";
  3. print "Hello, world!\n
  4.  
I logged into my unix server and created a folder called public_html and created
a file called first.html and placed the above source code in it.

I opened my Internet explorer and then typed "http://servername/~unixid/ and I was able see a file called first.html and when I clicked it I can see the entire code and not only "Hello world".

I created another file called first.cgi and placed the above source code and tried to open it still I cont see hello world printed on my screen.

It will be helpful for me to learn further If I konow how to run a CGI script.

Kindly help me.
Jul 26 '07 #1
4 1250
numberwhun
3,509 Expert Mod 2GB
You are going to have to make sure that you apache server(if that is what you are using for a web server) is setup to execute CGI scripts. Here is some documentation from the apache site to help you with that configuration.

If Apache isn't setup to "run" the cgi script, then it will just simply display it as text, as you have seen.

Regards,

Jeff
Jul 26 '07 #2
miller
1,089 Expert 1GB
Also, as the above documentation will tell you. You have to make sure that the cgi script is executable by the user running the web server.

chmod a+x yourscript.cgi

- Miller
Jul 26 '07 #3
Hi numberwhun and Miller

Thanks for the comments given.
I opened http://servername/~unixid Iam able to see all the .html files which are kept in public_html folder in my unix server.
I can also see the below line at the bottom of the page.
Apache/2.0.16 Server at <servernmae>Port 80.so Apache is Installed in my server.

Now my question is where will be the CGIbin directory present so that I can place my .cgi files there.
Jul 30 '07 #4
numberwhun
3,509 Expert Mod 2GB
You need to really read the link that I gave you in my last reasponse as t is question is answered in there.

If you locate your httpd.conf, you will want to locate the ScriptAlias directive. This is where apache is told to execute cgi scripts from.

I know that I am running Fedora Core 7 and on there Apache2 already had it pre-defined as /var/www/cgi-bin, while my localhost root directory for all my html code is /var/www/html (ie: my DocumentRoot).
I put my.cgi scripts in /var/www/cgi-bin and reference them in my browser as http://localhost/cgi-bin/script.cgi and they run just fine.

Regards,

Jeff
Jul 30 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Pierre-Yves | last post by:
Hello, I would like to prevent my perl program to be executed several times simultaneously (if the program is already running, I would like to display a message like "another instance of this...
0
by: Jon Monteleone | last post by:
Greetings, I posted a few days back and didnt get much of a response, so I figured I would post again with more detail. I am running gnome under fedora core 4. I want a kid to be able to drop a...
7
by: Advocated | last post by:
Hey all, thanks for taking the time to read this in the first place. Anyway, ill try and keep it simple. In my program, if i type $ man something it should read in the 2 words, man and something...
4
by: Jeff | last post by:
IDE: VS .NET 2003 OS: XP pro sp2 I'm developing a server application, clients will connect to it over the net and start different tasks.... When people sends a command to the program, the...
6
by: Benjamin Walling | last post by:
We have 109 remote offices all running Sybase ASA Server. We collect data from these offices and consolidate it into our main server. I have written a program that will read from each office and...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
8
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? --...
6
by: dspfun | last post by:
I would like to analyze my running c-program. What I would like to know for example is the range of the entire address space of my running c-program (memory reserved for/by the running program),...
12
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed...
7
TRScheel
by: TRScheel | last post by:
I have seen this question appear many times in the forums, so I am writing this to hopefully help those who have this question. First, a history lesson! Your earlier languages compiled to assembly...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.