SPONSORED LINKS

modules
Class Script

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

public class Script
extends java.util.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.html,v 1.1.1.1 2005/09/25 22:40:20 rswindell Exp $
Author:
Matthias L. Jugel, Marcus Meißner
See Also:
Module, Serialized Form

Constructor Summary
Script()
           
 
Method Summary
 void connect(java.lang.String host, int port)
          Configure the script module by reading the script PARAMeter.
 void disconnect()
          Get notified of disconnection.
 java.lang.String receive(java.lang.String s)
          This method is called when data is received.
 void setLoader(java.lang.Object o)
          Set the applet as module loader
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Script

public Script()
Method Detail

setLoader

public void setLoader(java.lang.Object o)
Set the applet as module loader
Specified by:
setLoader in interface Module
Parameters:
o - the object that is the applet (must be an Applet)
See Also:
module.Module, Applet

connect

public void connect(java.lang.String host,
                    int port)
Configure the script module by reading the script PARAMeter.
Specified by:
connect in interface Module
Parameters:
host - remote hostaddress - not used
port - remote port - not used

disconnect

public void disconnect()
Get notified of disconnection. Do nothing.
Specified by:
disconnect in interface Module

receive

public java.lang.String receive(java.lang.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)!
Specified by:
receive in interface Module
Parameters:
s - The string to test.
See Also:
peer.InputPeer