I need to have a server running that can:

  1. Take rest call. It triggers a script when a call is made
  2. The script checks if database is running or not.
  3. If running then reply back to client as Success else reply back as failure

I do not wish to use apache or any other major web server. Even simple scripts running on port will do. I am aware of python -m SimpleHTTPServer but I guess it only provides file access.

I can write a simple Java program that runs on a port and replies, but I am looking some simple solution


One of the more trivial services I can imagine is to run one from xinetd. That has the advantage that xinetd itself is relatively light-weight but will still handle all the networking stuff for you including logging and security restrictions such as request limiting, TCP-wrappers etc.

Install xinetd, when it is not already installed and define a custom service like /etc/xinetd.d/helloworld :

service helloworld
    disable         = no
    port            = 1234
    socket_type     = stream
    protocol        = tcp
    wait            = no
    user            = nobody
    server          = /usr/local/bin/hello-world.sh
    server_args     = test
    instances       = 1
    type            = unlisted

Reload/restart xinetd and you can test with a telnet localhost 1234.

The manual page man xinetd.conf has a pretty good description of the options available.


I would do that in BASH with the help of some simple nc commands:


nc -k -l -p PORT > tempfile

while true
    if cat tempfile | grep request;
        # Execute checker script
        # Reply back with nc
        : > tempfile # Clear tempfile
    sleep 1

This would require setting up the client with nc as well. Maybe setting up an nc listen command on the client is also required to receive the Success reply.

This script is far from complete, and you should also write the client for it, but it might give you some ideas.

The basic thing here is the use of nc. With the help of it, you can set up simple client-server architectures.


I ran into this while looking for a similar solution: Goexpose.

It allows triggering a number of tasks including shell, based on HTTP calls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.