Python command line oneliners

There is list of pretty useful python small command line oneliners available out of the box. That means if you already have installed python on your system (most Linux, *BSD, including OSX) then you can use it even if you are not python developer.

I love most way to create fake SMTP server:

$ python -m smtpd -n -c DebuggingServer localhost:25

If you develop using something else, but need to send emails and want to debug or just need something you can add to your Makefile this lines:

mail:
python -m smtpd -n -c DebuggingServer localhost:20025

And run make mail, voila you have running SMTP daemon on 20025 port. Easy!

Make JSON beautiful? Next oneliner:

$ echo '{"foo": "lorem", "bar": "ipsum"}' | python -mjson.tool

You can only wish more if you like to see it in color. Hope you noticed pipe support.

Full set of available HTTP services.

$ python -m SimpleHTTPServer
$ python -m CGIHTTPServer

Wanna use different port?

$ python -m SimpleHTTPServer 8080
$ python -m CGIHTTPServer 9080

It serve all files from local folder and below.

XMLRPC is not very popular this days, but you still able to debug remote servers: