![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
n00b question
here is the html file:
it takes your name. <HTML> <HEAD> <TITLE>Ben's CGI Test Page</TITLE> </HEAD> <BODY text = "aqua" bgcolor = "black"> <BASEFONT SIZE = 4> <h1 ALIGN = "center">Ben's CGI Test Page</h1> <hr WIDTH = 75% ALIGN = "center" size = "8"> <p>What is your name?</p> <form METHOD = "POST" ACTION="http://cgi-bin/test.cgi"> <input type = "text" NAME = "username" SIZE = 40 MAXLENGTH = 40 VALUE = "your name here"> <p><input type="submit" value ="send data">      <input type = "reset" value = "clear"></p> </form> </BODY> </HTML> here is the perl source: it prints out "hello" + whatever you entered...in theory. use CGI ' :standard';
$input = param('username');
print "Content-type: text/html \n\n";
print "hello $input";i'm using the sambar server to test the crap locally, http://localhost/page1.html is the html file on the server. the main directory is c:\Program Files\sambar63 under that we have the following: the html file is actually located in a subdirectory called "docs". the perl file is in the cgi-bin directory. i think i'm fucking this up from putting things in the wrong place or not looking for the right place. also, what's the difference between saving the perl file as as *.pl as opposed to *.cgi ? when i click to submit the name i get sent to the us government census page...WTF!?!
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#2 |
|
Expert Programmer
|
If you are getting sent to the US goverment census page, well I don't know why, but that is strange. Although one thing I noticed was the action says:
http://cgi-bin/test.cgi Shouldn't it be - cgi-bin/test.cgi If it has http://, doesn't it point to a remote location, not back to yoru server? It's the only thing I can think of, and might explain the bizaare gov page problem. I've never used Sambar, I like Abyss (http://www.aprelium.com/). It's really easy and great for testing/development stuff. Also has perl support w/ tutorial. The difference between *.cgi, and *.pl: I'm not quite sure, don't think it really matters. The only thign that does matter is the way the server views them. The server has to be set up to see *.cgi or *.pl. Hell I think you could call it *.whocares , just long as the server is set to look for that type. I've never worked with a whole lot of perl, but the only other thing that comes to mind is the first line. I always thought the first line of a .pl file was supposed to point to the cgi-bin or where ever the perl interpreter was. is that what your 'use' line does? Sorry, I've never donme it with a *.cgi extension before. Sorry I can't be of more help. Hope this helped a little though ![]() |
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
i'll try tomorrow, i know my free perl ide bitches about using the cgi functions if i don't save it as a cgi file.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
well, tried a billion variants, looking at the sambar docs now...
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#5 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 314
Rep Power: 4
![]() |
http://cgi-bin/test.cgi is looking for /test.cgi on a host called cgi-bin. nslookup tells me that doesn't exist but Firefox on my machine also sends me to the US Census site. Weirdness! I tried the obvious url mangling tricks some browsers will do to try to guess the URL but I didn't hammer away at it long; suffice it to say cgi-bin.com, www.cgi-bin.com etc. don't point to the US census site so it's still a mystery why we're getting forwarded there.
But as Booooze points out, you don't want the http:// at the start; you seem to be trying to refer to what's known as the 'relative URL' to your CGI script. You can use cgi-bin/test.cgi as Booooze suggests; this assumes cgi-bin is a subdirectory of the directory your starting point is in, or at least that it looks like it is from the outside of your webserver (in many cases, as on my webserver, the real layout is a little different and cgi-bin is not really under the document root). If you always want to point to a cgi-bin in the 'root' of your webserver, just use /cgi-bin/test.cgi. Alternatively, you can use http://localhost/cgi-bin/test.cgi (here, localhost is your machine, or more precisely the name of the loopback interface). You can even use your machine's actual name in here; on my box here I can do: http://vulture/cgi-bin/test.cgi (except that test.cgi doesn't exist of course). Anyway...other than this, there is a minor problem in your Perl code: Content-type: text/html \n\n I notice a space before the first backslash; generally this shouldn't affect anything but you don't need it and you never know. Second, \n\n sends two 'newlines' - if something between you and the browser is going to do end-of-line translations to fix this or if the browser is tolerant then all is well, but technically \n\n is newline newline and the correct terminator here is \015\012\015\012 (octal escapes for carriage return, line feed, carriage return, line feed). For some reason usually lines are separated by that two-char combination out there on the web (and in certain bizarre, obscure and archaic operating systems, like VMS and, ah, what's the other one? Ah yes, Windows I think it was called, but I don't think anyone uses it any more... )
__________________
"I'm not a genius. Why do I have to suffer?" |
|
|
|
|
|
#6 |
|
Professional Programmer
|
Try adding the path to the perl executable at the top of the file I think its somehting like ##!C:\Perl\bin\perl except that is my path you should use your own.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|