Solved

Posting by telneting to port 80

Posted on 1997-05-27
2
184 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

740 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