Download the tclhttpd package and cd to the bin folder. Start the tclhttpd daemon with this command:
tclsh httpd.tcl
The format to POST and read the HTML response from the generic website resembles this:
$ curl URL -d "postvar=postdata2&postvar2=postdata2"
Consider the following example:
$ curl http://127.0.0.1:8015/guestbook/newguest.html \
-d "name=Clif&url=www.noucorp.com&http=www.noucorp.com"
The curl command prints a response page like this:
<HTML> <Head> <title>Guestbook Registration Confirmed</title> </Head> <Body BGCOLOR=white TEXT=black> <a href="www.noucorp.com">www.noucorp.com</a> <DL> <DT>Name <DD>Clif <DT>URL <DD> </DL> www.noucorp.com </Body>
-d is the argument used for posting. The string argument for -d is similar to the GET request semantics. var=value pairs are to be delimited by &.
You can post the data using wget using --post-data "string". Consider the following example:
$ wget http://127.0.0.1:8015/guestbook/newguest.cgi \
--post-data "name=Clif&url=www.noucorp.com&http=www.noucorp.com" \
-O output.html
Use the same format as cURL for name-value pairs. The text in output.html is the same as that returned by the cURL command.
If you look at the website source (use the View Source option from the web browser), you will see an HTML form defined, similar to the following code:
<form action="newguest.cgi" " method="post" > <ul> <li> Name: <input type="text" name="name" size="40" > <li> Url: <input type="text" name="url" size="40" > <input type="submit" > </ul> </form>
Here, newguest.cgi is the target URL. When the user enters the details and clicks on the Submit button, the name and URL inputs are sent to newguest.cgi as a POST request, and the response page is returned to the browser.