I don’t get along with bash scripting. The syntax is so unusual, and I need it so infrequently, that I completely forget even the basics and have to relearn from scratch every time I have to write a script. After a recent success writing what would normally be a bash script in Python instead, I thought it would be a good idea to write a library that makes operations like piping with subprocesses much easier. You can find shell-scripter here on GitHub
It’s still early days for this project, but here’s a quick rundown of the features it has at time of writing:
Piping is supported with
.pipe() after a call to
run. You can chain as many of them as you would like.
from shell_scripter import run run("dmesg").pipe("grep", "usb")().show()
You may be wondering what the
().show() is doing on the example above. Shell-scripter doesn’t run anything until you call the command object. This allows you to build up chains bit by bit and then execute when everything is ready.
.show() just prints the output of the command to stdout.
If you want a command to execute without blocking the execution of your Python script, call the command object with