command shell
News
Version 2.4 released on June 30, 2011. Introduced configuration script. See the ChangeLog for other significant changes.Version 2.3 released on April 1, 2011.
Version 2.2 released on January 24, 2011.
Version 2.1 released on September 5, 2010.
Version 2.0 released on May 26, 2010. You will need to make changes to cs_defs.pl if you are upgrading from version 1.x. See the README file for details.
Download
cs.tgz
Description
This script provides a command shell to which you can add your own commands. Initial customization of the script is made using customize.pl. Make additional customizations by editing cs_defs.pl and cs_impl.pl.Detailed instructions for customizing the script appear in cs_defs.pl and cs_impl.pl.
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. Please also send me any generic changes to cs_defs.pl and cs_impl.pl such as new utility routines that might be useful to all script editors.
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-2011 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/>.
