poke poke - 29 days ago 5
Bash Question

Custom (interactive) shell with Python

I'm currently trying to make some small shell-like utility for a custom script I wrote, so I can easily work with it (it's rather simple, so an interactive shell would be perfect).

Do you have any resources for me on how to create a shell in Python? I spent googling for a while, but all I could find was information about IDLE and similar Python interpreters. But I would rather want to know how to write a completely custom and command line based shell.

My approach would be hooking the stdin/out for commands, but given that the Python library offers so many great utilities, I want to make sure there if there is no better way.

Answer

The cmd module in the standard library could be a start -- if you have any trouble using it, please post more specific questions (ideally with some toy example showing what you're trying to achieve and what you're getting instead!).

Comments