Writing your own shell in php

I’ve always wanted to write my own simple shell in php.  Call me a glutin for punishment, but it seems like something that a lot of people could use to be able to do… If your web app had a command line interface for various things… like looking up stats, or users, or suspending naughty accounts, or whatever…. wouldnt that be cool and useful?  Talk about geek porn.  Anyways this this morning I got around to tinkering with the idea, and here is what i came up with… It’s rough, and empty, but its REALLY easy to extend and plug into any php application.

apokalyptik:~/phpshell$ ./shell.php

/home/apokalyptik/phpshell > hello

hi there

/home/apokalyptik/phpshell > hello world

hi there world

/home/apokalyptik/phpshell > cd ..

/home/apokalyptik/ > cd phpshell

/home/apokalyptik/phpshell > ls

shell.php

/home/apokalyptik//phpshell > exit

apokalyptik:~/phpshell$ ./shell.php

See the source here: shell.phps

7 thoughts on “Writing your own shell in php

  1. I hadn't seen that one… I saw another one a while ago… I actually don't mean this to be a shell in the sense that bash is a shell you work on your system inside of, but an interface to an application.

    I imagine being able to, say, manage my wordpress blog posts with a simple class and the command line… or whatever…

    Mainly though it's an academic exercise. Just something I always wanted to try 😀

Leave a Reply