command shell
Download
cs.tgz
Description
This script provides a command shell to which you can add your own commands. Customize the script by editing cs_defs.pl and cs_impl.pl.When I make a new shell, I copy all the files and rename them to match the function that is being implemented. For example, I might name them admin.pl, admin_defs.pl, and admin_impl.pl. Except for this renaming, I encourage you to make all your customizations in the cs_defs.pl and cs_impl.pl files unless the main script needs fixing or improvements. In the latter case, please send those changes to me.
Detailed instructions for customizing the script appear in cs_defs.pl and cs_impl.pl.
The basic script provides three or four modes of operation:
| main | this is the mode to which you will typically add your own commands |
| system | execute operating system commands (via system function) |
| perl | evaluate perl expressions |
| cgi | (optional) execute commands on a server |
The cgi mode is only enabled after one or more calls to addCGI. (See cs_defs.pl for more information.) This mode communicates with scripts on a remote server. These scripts appear in the server directory of the distribution. Install the scripts on the server and be sure they are executable by the web server.
CGI mode is derived from version 0.17a of CGI-Shell by Michael Pradel. As of this writing, CGI-Shell is up to version 0.21. Feel free to upgrade the script to work with the latest version; if you do, please send those changes to me.
Example
Here is a sample session in a version of cs.pl without any customization:
./cs.pl
main> help
e!command Execute a sample <command>
!command Execute a system <command>
p!statement Execute a Perl <statement>
main Process in sample mode
system Process in system command mode
perl Process in Perl mode
edit file Edit <file> with emacs
reload Reload this program
quit Exit this program
main> help system
System mode and the ! prefix allow you to execute system commands.
main> !ls
GPL README cs.pl cs_defs.pl cs_impl.pl server
main> help perl
Perl mode and the p! prefix allow you to execute Perl expressions.
main> p!$ENV{EDITOR}
/usr/bin/emacs
main> p!@modes
main,system,perl
main> exit
Send me reports of any errors or suggestions you have about my Perl scripts.
The code described on this page is Copyright 2004, 2005, 2006, 2007 Tony Lewis <tlewis@exelana.com>.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
