Run shell scripts and Linux commands in python. Usage of redirection, pipe are identical to bash.
>>> import pybash
>>> files = pybash.run('find ./example-dir')
>>> print(files)
./example-dir
./example-dir/example2.png
./example-dir/example3.mp3
./example-dir/example1.doc
>>> pybash.run('hexdump -C ./README.md | tr "[:lower:]" "[:upper:]" > hex.out')
>>> job = pybash.run('sleep 10 && echo "wakeup!"', asynchronous = True)
>>> job.isFinished()
False
>>> job.wait()
# after 10 seconds
'wakeup!'
>>> job.isFinished()
True
>>> pybash.run('echo hello', get_return_code = True)
0
Pybash sets shell = True
for convenience. Users should ensure the commands are safe to run. Malicious commands like shell injection may put your system at risk!
The MIT License (MIT)