•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 402,616 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,237 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 839 | Replies: 4
![]() |
•
•
Join Date: Aug 2007
Posts: 154
Reputation:
Rep Power: 0
Solved Threads: 0
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
# ./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
•
•
Join Date: Oct 2007
Posts: 267
Reputation:
Rep Power: 1
Solved Threads: 26
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
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 10:38 pm. Reason: significant typo
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
•
•
Join Date: Oct 2007
Posts: 267
Reputation:
Rep Power: 1
Solved Threads: 26
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
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 24th, 2008 at 11:24 pm.
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
![]() |
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
ad ad server ad serving advertising architecture backup beta business centro crash daniweb database dell development doubleclick enterprise google hyper-v internet linux longhorn mail microsoft mmorpg news novell open qmail red hat rhel scsi server server 2008 smtp software source suse upgrade vmware windows windows server workspace
- Bash Mail script help (Shell Scripting)
- Problems starting Oracle (Oracle)
- learning php (PHP)
- HJT log for review (Viruses, Spyware and other Nasties)
- RedHat Network Server (*nix Hardware Configuration)
- I had a experience of a website coded in PHP (PHP)
- Stupid Search200 (Viruses, Spyware and other Nasties)
- Search200 (Web Browsers)
- Prosearching passthrough bar problems..getting rid of it (Viruses, Spyware and other Nasties)
Other Threads in the Shell Scripting Forum
- Previous Thread: Variable check
- Next Thread: Help with while loop and sed


Linear Mode