Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

How can I run a .cgi script?

Jun 16, 2009 12:25PM 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?

Thanks,
Frank.

Discussion is locked

- Collapse -
What language is that script?
Jun 17, 2009 12:40AM PDT
- Collapse -
Perl.
Jun 17, 2009 3:14AM 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.

Thanks.

- Collapse -
That's untrue if it was PERL.
Jun 17, 2009 3:51AM PDT

Research HOW TO RUN A PERL SCRIPT.

- Collapse -
Yes.
Jun 17, 2009 4:18AM PDT

perl perlname.pl

but

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.
Jun 17, 2009 6:58AM PDT

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.
Jun 17, 2009 7:18AM 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.
Jun 17, 2009 9:49AM PDT

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<b>Hello, world!</b>
</body>
</html>

Is the rest of the code for just HTML output.

- Collapse -
I just want say Hello ...
Jun 17, 2009 9:57AM 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.
Jun 17, 2009 10:14AM PDT

Try just the one liner.

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

No.

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

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

- Collapse -
CGI is not Perl
Jun 24, 2009 9:34AM 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
Jun 24, 2009 9:55AM PDT