Solved

Posting by telneting to port 80

Posted on 1997-05-27
2
178 Views
Last Modified: 2013-12-25
One of my cgi scripts telnet's to port 80 of a server with an intent to POST something..
The script name is post.cgi and the variable that needs to be passed is "numb"
How would I post the numb string to post.cgi
First I try telneting to port 80
then I type "POST /cgi-bin/post.cgi HTTP/1.0"

What do I do next to post numb=1 to post.cgi?

Thanks
0
Comment
Question by:chiefarcher
2 Comments
 
LVL 2

Accepted Solution

by:
mkornell earned 100 total points
ID: 1828107
You output to telnet should look like:

----begin output----
POST /cgi-bin/post.cgi HTTP/1.0
Content-length: ?????

numb=some_url_encoded_data
----end output----

(Of course, don't send the lines starting with '----' :-)

After the initial POST line, you need to send appropriate header lines, of the form "Header: header information"

You really, _really_ should send a Content-length: header.  This tells the server how much data (in bytes) you are going to be sending.  Some servers require this to be set, and others, if it is not set, will read all passed.

Other headers you might want to set are User-Agent: and Host:.

After the header lines, you need to send a blank line. This tells the server on the other end that you've finished sending headers and are about to send data.

Then, send your POST data. How the data will be interpreted is totally up to the receiving end, but typically it will be expecting a name1=value1&name2=value2 format.  (Sounds like this is case for your needs.)

For a full description of the HTTP protocol, refer to RFC 1945 (HTTP/1.0) or RFC 2068 (HTTP/1.1).  These can be found at http://info.internet.isi.edu/1/in-notes/rfc

Just curious: Is your post.cgi script written in Perl? If it is, there are Perl libraries that will take care of all the HTTP overhead for you.  Check out the libwww bundle at CPAN ( http://www.perl.org/CPAN ).

--mark;
0
 

Author Comment

by:chiefarcher
ID: 1828108
Beautiful
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question