Web Hosting, Design, & Coding forum

General discussion

How can I run a .cgi script?

by FrankQC / June 16, 2009 12:25 PM PDT

.. I don't want to run Apache or anything like that. I don't want to subscribe to a website and upload the script there.

Is there any way of basically running the .gci w/o having to do any of that hasselful stuff?

Is there a web browser that interprets .cgi?


Discussion is locked
You are posting a reply to: How can I run a .cgi script?
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: How can I run a .cgi script?
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
What language is that script?
by R. Proffitt Forum moderator / June 17, 2009 12:40 AM PDT
Collapse -
by FrankQC / June 17, 2009 3:14 AM PDT

I'm running Linux so Perl came with it. I programmed my small script (just saying 'hello') because I want to see if it works. I searched all over Google but they keep saying you need a web server.


Collapse -
That's untrue if it was PERL.
by R. Proffitt Forum moderator / June 17, 2009 3:51 AM PDT
In reply to: Perl.


Collapse -
by FrankQC / June 17, 2009 4:18 AM PDT

perl perlname.pl


perl perlname.cgi

Instead of seeing "hello world" I see print "print "Content-type: text/html\n\n";"

All I'm supposed to see was "hello world"

Collapse -
Remember I can't see the script.
by R. Proffitt Forum moderator / June 17, 2009 6:58 AM PDT
In reply to: Yes.

It may be emitting html and more. For perl it's one line:

print "Hello World\n";

What is your script have?

Collapse -
My script.
by FrankQC / June 17, 2009 7:18 AM PDT

print "Content-type: text/html\n\n";
print "Hello!\n";

I'm trying to display "Hello!" using HTML in PERL. So really if it was in the cgi-bin of the web server it would show Hello! rather than an output of:

print "Content-type: text/html\n\n";
print "Hello!\n";

(which is currently what I have when I open the file with my browser)

I wanna to locally run the .cgi script and see how it operates without the use of a web server.

Collapse -
So that's just the beginng.
by R. Proffitt Forum moderator / June 17, 2009 9:49 AM PDT
In reply to: My script.

<title>Hello, world!</title>
<b>Hello, world!</b>

Is the rest of the code for just HTML output.

Collapse -
I just want say Hello ...
by FrankQC / June 17, 2009 9:57 AM PDT

... without having to run the .cgi on a server. I want to run the .cgi locally to test it out.

The two lines of code I sent were correctly programmed, I just need to know how to run it as a .cgi so the browser sees it as a server-based action.
I don't own a web server (no apache or anything) so I can't upload my .cgi there.

Collapse -
Then you only need ONE line.
by R. Proffitt Forum moderator / June 17, 2009 10:14 AM PDT

Try just the one liner.

"Is there a web browser that interprets .cgi?"


Collapse -
(NT) k.
by FrankQC / June 17, 2009 10:17 AM PDT
Collapse -
k I got it working..
by FrankQC / June 22, 2009 12:32 PM PDT

.. I had to set up a server... Took me a long time to make it work.

Collapse -
CGI is not Perl
by MeatyByte / June 24, 2009 9:34 AM PDT

CGI is not Perl.

CGI is an interface between a web server and an external application. Only an interface. It is NOT a programming or scripting language.

CGI "Scripts" are those scripts which comply with the CGI interface. but they can, and are, written in many different scripting languages.

Some CGI's are Perl. Some are C++ code. Some are in other languages.

For the Perl scripts, you can run them from the command line of Windows or Linux if you have Perl installed. For C++ code you can run it directly like you can run any executable. This doesn't mean the script will behave well when you do this, as they were probably expecting to be called from a web server with parameters and not from the command line.

Collapse -
(NT) I know
by FrankQC / June 24, 2009 9:55 AM PDT
In reply to: CGI is not Perl
Popular Forums
Computer Newbies 10,686 discussions
Computer Help 54,365 discussions
Laptops 21,181 discussions
Networking & Wireless 16,313 discussions
Phones 17,137 discussions
Security 31,287 discussions
TVs & Home Theaters 22,101 discussions
Windows 7 8,164 discussions
Windows 10 2,657 discussions


Your favorite shows are back!

Don’t miss your dramas, sitcoms and reality shows. Find out when and where they’re airing!