The web services paradigm of development is based on the Unix philosophy of “small is good”.  Web services should do one job, and do it well, allowing users to develop complex solutions by combining small, reliable and proven services.
Why not then, expose the power of familiar Unix commands like sort, grep, gzip… to the web?

Here is a proof of concept python script (Python 2.3 version) to demonstrate.

Start services:

$ ./to_web.py -p8008 sort &
Thu Mar 27 13:45:54 2008 sort server started - 8008
$ ./to_web.py -p8009 gzip &
Thu Mar 27 13:46:29 2008 gzip server started - 8009

Use the services:

$ for i in {1..10}; do echo ${RANDOM:0:2}; done | \
> curl --data-binary @- "http://swat:8008/sort+-nr" | \
> curl --data-binary @- "http://swat:8009/gzip" | \
> gunzip
97
37
23
23
21
18
11
11
10
10

In my position, we have a database with host information – which has a command line interface. This tool has dependencies which are a painful to resolve. With to_web.py, we can turn the command line tool into a web service and access the data without having to satisfy those additional dependencies.

This is guest post by my esteemed colleague Adam Fokken. He can be reached here: Sadly, he does not have a blog.

4 Responses to “Exposing command line programs as web services”

  1. Leonardo Says:

    Wow. Just these days I was pining for a simple way to share a plain text log file to a coworker.
    Again, wow. This is beyond cool.

  2. Mac Says:

    This would be a great idea!

  3. Web Services Company Says:

    small software development companies are dynamic…hmm i think it is going to work a lot small projects are successful projects.It is the begining process of success of the business men.think about it…..

  4. The Doctor Says:

    ? So this concept is to expose only specific cmds to the web? How does this differ fr AjaxTerm+SSL?

Leave a Reply

If Wordpress eats your comment (shell output, loops, ex..) email the text to me.