Simple script to use / run a fake process on a port

While testing some shell scripts I needed a simple way to tie up a port on the server to cause the shell scripts to error out.

I did some googling and couldn’t find any way to do this in pure bash but if you have NodeJS installed on your server it’s as simple as this:

node -e 'require("http").createServer(function(){}).listen(PORT);'

Simply replace PORT with the port number you wish to use. If anyone knows a way to do this in pure bash please let me know.