943,697 Members | Top Members by Rank

Ad:
May 23rd, 2008
0

HTTP server in bash

Expand Post »
The server should be called as follows:

# ./bashwebserver.sh port [root]

Where port is a mandatory argument to specify the port number the server should listen on, and root
is an optional argument to specify the web server's root directory.

P.S:

● If the root directory is not specified, use the current directory as root
● Use the netcat (sometimes called nc) command to listen on incoming connections
● The web server should at least understand the HTTP GET command
● The web server should correctly return the following status codes: 200 OK, 403
FORBIDDEN, 404 NOT FOUND
● The web server should correctly return a Content-Type header, at least for text/plain,
text/html and application/octet-stream (for all files which do not match any of the
other content types)
● If the web server receives a request for a directory, it should return a directory listing (does
not need to have clickable links). Optionally, you can return an index.html file instead, if
one exists.

any guide is appreciated
Similar Threads
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
May 23rd, 2008
0

Re: HTTP server in bash

Hi again,
I don't need the advanced script, just I need the sample one, to get and have the idea ...
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
May 23rd, 2008
1

Re: HTTP server in bash

Hey There,

Bash doesn't natively support sockets programming, like in Perl. Are you looking to write a bash script that runs a separate "http server" program?

Also, if you've already gotten started, can you post that. This way anyone who checks this post will know where you're at and can help you more

Best wishes,

Mike
Last edited by eggi; May 23rd, 2008 at 11:38 pm. Reason: significant typo
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
May 24th, 2008
0

Re: HTTP server in bash

Check this link.
Reputation Points: 10
Solved Threads: 5
Junior Poster in Training
radoulov is offline Offline
54 posts
since Feb 2007
May 25th, 2008
0

Re: HTTP server in bash

Ah, yes,

That's running a shell on a port, technically, but it is a clever solution. I don't think it's possible to write a standalone bash http server that doesn't depend on inetd running the bash shell.

I may be wrong. If anyone has any more examples like this one, I definitely would be interested. Very cool.

I wrote this perl shell runner that could be combined with that to emulate httpd, but it would easier to just write the web server in Perl straight up.

Cool link

Thanks,

Mike
Last edited by eggi; May 25th, 2008 at 12:24 am.
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: Variable check
Next Thread in Shell Scripting Forum Timeline: Help with while loop and sed





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC