A Bash web server

One Liners

© Lead Image © valenty, 123RF.com

© Lead Image © valenty, 123RF.com

Article from Issue 250/2021
Author(s):

With one line of Bash code, you can create a Bash web server for quickly viewing the output from Bash scripts and commands.

For people who do a lot of work with command-line tools or Bash code, having a Bash web server could be very handy. I was really amazed that in one line of Bash code I was able to create web servers that could:

  • Send the output from a Bash command directly to a browser page
  • Create diagnostic pages using standard Linux tools
  • Create pages that view Raspberry PI GPIO pins
  • Create a page to toggle a Rasp PI GPIO pin

One-Line Web Servers

While a number of minimal, one-line web servers exist in most programming languages [1], you can create a Bash web server using the networking utility nc (or netcat) as follows:

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Gemini Protocol

    Create Gemini pages to show sensor data or control a Raspberry Pi rover.

  • OpenWrt on a Pi

    Light open source router firmware breathes new life into your old Raspberry Pi.

  • Gnublin

    Embedded Linux doesn’t have to be rocket science, which the Gnublin board clearly shows. If you want to learn how to read sensors, flip switches, and switch LEDs on ARM Linux, this tiny machine is perfect for your research.

  • Julia on the Pi

    Create GUIs and a web app that connects to sensors.

  • Elixer

    The Elixir programming language on a Raspberry Pi lets you create distributed projects in just a few lines of code.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News