Exposing command line programs as web services
March 27th, 2008
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.


March 28th, 2008 at 6:19 am
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.
March 31st, 2008 at 12:10 pm
This would be a great idea!
April 24th, 2008 at 1:13 am
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…..
June 12th, 2009 at 10:18 pm
? So this concept is to expose only specific cmds to the web? How does this differ fr AjaxTerm+SSL?