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

  • 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.

  • Kitchen Timer

    A simple kitchen helper with two timers assists budding chefs in coping with dishes that are unlikely to be ready at the same time.

  • Gnuplot

    Use Gnuplot with command-line utilities.

  • Bash 4

    Despite the Bourne-again shell's biblical age and high level of maturity, developers continue to work on it. We take a look at the latest Bash release.

  • ARM64 Assembly and GPIO

    Reading, writing, and arithmetic with the Raspberry Pi in ARM64 assembly language.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News