Shell servlet 2.1

    It is a Java servlet lets you execute commands on your server. So you can use this tool for remote host administration (copy files, do backup, reboot etc.) Servlet supports WAP/WML, so you can do this even from your mobile phone.

How to use it:

a) copy shellPackage.jar into WEB-INF/lib directory

b) describe Shell servlet in your web.xml file:


    <servlet>
     <servlet-name>ShellServlet</servlet-name>
     <servlet-class>com.jsos.shell.ShellServlet</servlet-class>
    </servlet>

c) describe a mapping for this servlet:


   <servlet-mapping>
    <servlet-name>ShellServlet</servlet-name>
    <url-pattern>/servlet/ShellServlet</url-pattern>
   </servlet-mapping>

    the usage is:

    http://your_host/servlet/ShellServlet

Shell servlet demo

you can directly type this request, add a link to your page or insert iframe with src attribute points to this servlet.

After the opening servlet's screen just type your host command and press Enter. E.g. some like this:

ls -la for Unix based host or
cmd.com /c dir for Windows 2000/XP

    You can change common settings for this servlet in the configuration file. Configuration file must be provided as an initial parameter for this servlet. Parameter name is config and this parameter contains a name of text file with your settings.

So in your web.xml you can have some like this:


    <servlet>
     <servlet-name>ShellServlet</servlet-name>
     <servlet-class>com.jsos.shell.ShellServlet</servlet-class>
     <init-param>
      <param-name>config</param-name>
      <param-value>path_to_your_configuration_file</param-value>
     </init-param>
    </servlet>

Configuration file is a text file describes user's settings in the form of parameter=value. Empty lines and any line starts with # or // are ignored. Current version supports the following list of parameters:
 
# title. Default value is Coldbeans Shell Servlet
title=My host

# prefix. Default value is empty.
# e.g. for XP-host you can set prefix=cmd.com /c
# and type your commands without this part.
prefix=cmd.com /c

# Frames settings (how to split the screen between the command line and output window). Default value is 80%,20%
frames=80%,*

# Background color for shell's screen. Default value is #000000
bgcolor=#000000

# Foreground color for shell's screen. Default value is #008000
fgcolor=#008000

# Background color for command's screen. Default value is #D3D3D3
bgcolor1=#D3D3D3

# Foreground color for command's screen. Default value is #000000
fgcolor1=#000000

# Font size. By default is current browser's font.
size=1

# Font face. By default is current browser's font.
face=Verdana

Custom interface

You may redesign HTML screens and use your own interfaces. For example you may use your own forms for posting commands to servlet. You can execute HTTP POST command to the following URL: http://your_host/servlet/ShellServlet?act=3. Parameter cmd must contain your shell command. For example, create HTML form with text input field named cmd and action points to http://your_host/servlet/ShellServlet?act=3.

For JSP integration check out also Hosts scripts tag from Coldtags suite.

    For downloading:  shellPackage.jar   
    Sample of configuration file:  shellcnf

  © Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.

Also in JSOS: