Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

pypm install chut

How to install chut

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install chut
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
0.9 Available View build log
0.9Never BuiltWhy not?
0.1 Available View build log
Linux (32-bit)
0.9 Available View build log
0.1 Available View build log
0.9Never BuiltWhy not?
0.1 Available View build log
Linux (64-bit)
0.9 Available View build log
0.1 Available View build log
0.9Never BuiltWhy not?
0.1 Available View build log
0.9 Available View build log
Lastest release
version 0.9 on Apr 4th, 2013


Chut is a small tool to help you to interact with shell pipes and commands.

Basically it will help to write some shell script in python

This is more like a toy than a real tool but... It may be useful sometimes.

It's tested with py2.6+ and py3.2+:


Full documentation can be found here

Quick quick start

Get the chutify script:

$ wget https://raw.github.com/gawel/chut/master/docs/_static/binaries/chutify
$ chmod +x chutify

Write a console script:

$ cat << EOF > myscript.py
from chut import *

__version__ = '0.1'

def mycmd(args):
    """Usage: %prog [options] <directory>

    Print all chut scripts found in <directory>


    for filename in find('-name *.py') | grep('@console_script'):

Run chutify in development mode:

$ ./chutify --devel
chmod +x bin/mycmd

And use/debug the newly created script:

$ ./bin/mycmd -h

When your script is ready for production then generate the standalone version:

$ ./chutify
chmod +x dist/scripts/mycmd

Also have a look at the examples.


Using pip:

$ pip install chut

This will also install docopt and allow you to use the @console_script decorator.

Another option is to get chutify standalone version:

$ wget https://raw.github.com/gawel/chut/master/docs/_static/binaries/chutify
$ chmod +x chutify

Quick start

Import the shell:

>>> import chut as sh

Get a file content if it contains "Chut":

>>> grep_chut = sh.cat('README.rst') | sh.grep('Chut')
>>> if grep_chut:
...     print(grep_chut | sh.head("-n1"))

Redirect output to a file:

>>> ret = (grep_chut | sh.head("-n1")) > '/tmp/chut.txt'
>>> ret.succeeded
>>> print(sh.cat('/tmp/chut.txt'))

Or to stdout:

>>> sh.cat('/tmp/chut.txt') > 1  # doctest: +SKIP

Redirect stdout to stderr:

>>> sh.cat('/tmp/chut.txt') > 2  # doctest: +SKIP

Run many command with a pool of processes:

>>> [ret.succeeded for ret in sh.ls.map(['.', ['-l', '/tmp']])]
[True, True]

Use docopt to write a console script. This script will take an iface as argument and return a code 1 if no address is found:

>>> @sh.console_script
... def got_inet_addr(args):
...     """Usage: got_inet_addr <iface>"""
...     if sh.ifconfig(args['<iface>']) | sh.grep('inet addr:'):
...         return 1

>>> if __name__ == '__main__':
...     got_inet_addr()

Subscribe to package updates

Last updated Apr 4th, 2013

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.