6 ms·
Webserver in bash (2007)
- frewsxcv 13y agoHardly implemented in Bash, it uses nc. I have a friend who implemented using no external binaries in Bash. I'll ask him and see if I can get it EDIT: I think this is it: http://ur1.ca/f2ozi http://ur1.ca/f2ozi
- dhamidi 13y agoThat is a HTTP client written in bash.
- president 13y agoThat uses wget, curl, lynx...
- GregorStocks 13y agoIt looks like it'd work fine without them, it just uses them if they're available (presumably they're more efficient/reliable than using straight bash)
- D9u 13y agoBASH = Bourne Again SHell You could do the same in zsh, or another compatible shell, using netcat, so while semantics may be on your side, the server does run in a BASH shell. I was under the impression that wget, curl, etc, are external binaries and not built in to the BASH shell.
- M4v3R 13y agoIt is a convention that when you say "written in bash" it means "using bash language and standard *nix binaries". Bash alone can't do anything, nearly every keyword in it is actually a binary, including "echo", "true" and "false" or "[" used in if statements, which you can usually find in /bin or /usr/bin. You couln't write simplest bash scripts without using any binaries. Netcat (nc) is built in to nearly every system that has bash. Wget and Curl on the other hand, are not.
- krunaldo 13y agoWrong! echo, true, false and [ are builtins in bash and are in the binary. You can even do TCP/UDP through bash by using the pretend redirect files /dev/(tcp|udp)/$host/$port. curl or wget exists on most systems by default in a minimal installation now days, nc does not, but if you run a normal installation you will get it though.
- JosephRedfern 13y agojosephredfern@ubuntu:~$ which [ /usr/bin/[
- deleted 13y ago[deleted]
- Daviey 13y agoI disagree about those 'keywords' not being part of bash: $ echo $SHELL /bin/bash $ type echo true false [ echo is a shell builtin true is a shell builtin false is a shell builtin [ is a shell builtin
- JeremyMorgan 13y agoI was just thinking about this the other day and wondering if anyone had tried it yet. Too lazy to look for it. Throw a way to do some real routing in there and you might be on to something. It's an interesting idea, with the trends of blogs (like mine even) going to octopress, simplifying the serving of static text is greatly beneficial.
- 1337p337 13y agoFun times in bash, but very boring in the Inferno shell: listen -A 'tcp!*!9000' { {req := "{sed '/^\r$/q'}; echo 'HTTP status and headers elided'; echo $req} & }
- softbuilder 13y agoIf you're on OS X, change the netcat command to: nc -l localhost 9000