Tuesday, April 21, 2015

Bashttpd - Self contained bash webserver in one single short script! =)

I was thinking about coding something like this before I found something that was pretty much working already here: Original project

All I did was modify it a bit, changed the default settings for remote browsing, fixed binary file transfers and added a start option.

To use it first install tree, socat: 
 sudo apt-get install tree
 sudo apt-get install socat

Then download the latest copy of bashttpd from here:

https://github.com/AdamDanischewski/bashttpd

Just drop it on a host machine (that has bash) and start it up like this:

$192.168.1.101> bashttpd -s

On the remote machine you should be able to browse and download files from the host server via any web browser by visiting:

http://192.168.1.101:8080 

Fun!! =) 

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. I am using this in our surveillance system instead of Apache/nginx/etc. I like the fact that I have so much control and that I don't have to learn someone else's complex configuration.

    I added a simple PUT ability. Search the script for the following code line occurances, then modify as I show below. Modify this for 204 response:

    declare -a HTTP_RESPONSE=(
    [200]="OK"
    [204]="No Content"
    [400]="Bad Request"
    [403]="Forbidden"
    [404]="Not Found"
    [405]="Method Not Allowed"
    [500]="Internal Server Error")

    (the line with 204 is what you add)

    and modifying to allow PUT:

    [ "${REQUEST_METHOD}" == "GET" ] || \
    [ "${REQUEST_METHOD}" == "PUT" ] || fail_with 405

    (the little PUT checking section is what you add) End your parsing code with:

    send_response 204
    exit



    Question for you, I wonder if any modification is needed for this:
    Our surveillance web page plays the videos in object tags. Video is recorded in 6 minute-long segments, and we want some way of playing segments serially without any intervention needed...just load any segment and subsequent video is played seamlessly. Note that the HTML object tag alone is being used to both list the filenames and play video when one of the files is clicked. We would do this for all camera recordings simultaneously to simulate a full system playback, each camera having its own object tag. (Of course stop and start would be done with javascript for ease of synchronizing the launch of the all-play playback.)

    Any thoughts as to how to modify bashttpd? I'll jump in and try to figure it out while hoping for your thoughts. Thank you!

    ReplyDelete