Writing your own shell in php

Gravatar

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


Posted on : Aug 03 2008
Posted under API, Business, MySQL, Personal, Random Thoughts, Software Development, cli, linux, php, web stuff |

4 People have left comments on this post

Aug 4, 2008 - 09:08:36
Gravatar  Joseph Scott said:

Have you looked at phpsh (http://www.phpsh.org/)?

Aug 4, 2008 - 09:08:11
Gravatar  Apokalyptik said:

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 :D

Sep 18, 2008 - 06:09:55
Gravatar  Adam said:

do you know how to make a simple shell in C?

Sep 19, 2008 - 11:09:12
Gravatar  apokalyptik said:

haha… I wish I did. I’ve never been that handy with compiled languages.