Wednesday, March 17, 2010

netcat one line webserver

Modified from the wikipedia article. Sets up a webserver on the local box (using only the netcat command) and serves a single file (called myfile) to all clients.

while true;do ( echo -e "HTTP/1.0 200 Ok\n\r"; cat myfile; ) | nc -l 8080 ;done

No comments: