Class modules.Script
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class modules.Script

java.lang.Object
   |
   +----java.util.Dictionary
           |
           +----java.util.Hashtable
                   |
                   +----modules.Script

public class Script
extends Hashtable
implements Module
A very simple scripting module. It takes pairs of pattern and text and sends the corresponding text when the pattern matches. Each pattern is only matched once per connected session.
Scripts:
<PARAM NAME=script VALUE="pattern|text|...">
A script contains of pairs of pattern and text strings. If the pattern is matched against the output from the remote host, the corresponding text will be sent. Each pattern will match only once per session. A session is defined by connect and disconnect.

Thus it is possible to program an autologin as follows:

"login:|leo|Password:|mypassword|leo@www|ls"
Newlines will be added automatically to the string sent! At the moment the order of the pattern and text pairs is not relevant.

It is possible to prompt the user for input if a match occurs. If the corresponding text is a string enclosed in braces ([] or {}) a dialog window is opened with text as prompt. A special case is an empty prompt in which case the pattern will be shown as prompt. "[Your name:]" would open a dialog window with the text "Your name" as prompt. Curly braces have a special meaning; any user input will be shown as "*" which makes it possible to program password prompts. Example: "{Your password:}".

A special match like: "login:|[]" can be used to open a dialog and display "login:" as prompt. This works for "{}" as well.

Version:
$Id: Script.java,v 1.6 1997/11/03 10:25:57 leo Exp $
Author:
Matthias L. Jugel, Marcus Meißner
See Also:
Module

Constructor Index

 o Script()

Method Index

 o connect(String, int)
Configure the script module by reading the script PARAMeter.
 o disconnect()
Get notified of disconnection.
 o receive(String)
This method is called when data is received.
 o setLoader(Object)
Set the applet as module loader

Constructors

 o Script
  public Script()

Methods

 o setLoader
  public void setLoader(Object o)
Set the applet as module loader
Parameters:
o - the object that is the applet (must be an Applet)
See Also:
Module, Applet
 o connect
  public void connect(String host,
                      int port)
Configure the script module by reading the script PARAMeter.
Parameters:
host - remote hostaddress - not used
port - remote port - not used
 o disconnect
  public void disconnect()
Get notified of disconnection. Do nothing.
 o receive
  public String receive(String s)
This method is called when data is received. It tries to match the input to the list of patterns and sends corresponding text on success. If the response is [] or {} the user will be prompted with the matching text. You can modify the prompt string by entering it inside of the brackets or curly braces (e.g. [Enter your id:]). In case of curly braces the input area will not show the typed in text (for passwords)!
Parameters:
s - The string to test.
See Also:
InputPeer

All Packages  Class Hierarchy  This Package  Previous  Next  Index