HTTP and HTML tools

Quick one-page serving web server

This snippet uses nc (netcat) to strictly serve index.html over port 8888. Parameterize or modify to your liking.

while true; do
    echo -e "HTTP/1.1 200 OK\nContent-Type: text/html\n\
Content-Length: $(du -b index.html | awk '{print $1}')\n\
Connection: close\n\n $(cat index.html)\r\n" |
    nc -lp 8888
    sleep 1
done

HTML listing via Tree

Build a one-page directory listing of your entire site, sorted by mod time.

tree -I index.html --matchdirs -t -H base_url \
     -T "Dir Listing" --noreport . > tree.html

The few key arguments to the tree command:

Create a recursive html directory listing for your entire site.

tree -R -L 1 --dirsfirst -H base_url \
     -T "Dir Listing" --noreport . > tree.html

Curl

Log into site via HTTP POST and save cookie.

curl --cookie-jar cookie.txt 'http://www.server.com' \
    -d "user=<user>&password=<password>"'

Download private_file.zip via the previously saved cookie. Follow any redirect.

curl --cookie cookie.txt --location \
    "http://www.server.com/private_file.zip" -O 

Other HTTP POST alternatives:

curl -v <url> -d @data_post.txt
w3m -post data_post.txt <url>

Questions, comments? Connect.