Automated Login

Project:Write a script to connect to a predetermined host system, use a known userid and password to login and launch a host application.

Algorithm:The host address and other configuration items can be stored in a session file or a new session can be created and these values set with script commands. A command may be issued to initiate the connection to the host computer, or verify that a live connection exists. Once a connection has been made, the process is to wait for the expected prompts from the host, and respond by sending the appropriate characters.

Relevant Commands and Functions:
CONNECT — establish the connection and optionally open a specified SES file
CONNECT( ) — indicates whether the session is connected
SEND — send a string of characters to the host.
SHOW — Display each script command as it is executed.
WAIT DELAY — wait for the specified delay period
WAIT STRING — wait for the specified prompt

See Also:
CONNCONFIG — configure connection parameters
LOAD — Load the specified session file
SET CONNECTION — specify the connector used
SEARCH( ) — Returns the position of a string in the session window
WAIT SCREEN — wait for a new screen to be displayed
WINDOW OPEN SETTINGS — Load the specified session file

A Brief Example

SHOW
CONNECT "Vax"
WAIT STRING "Username:" QUIET "00:00:03"
IF SEARCH(,,,"Username",) <> (-1)
BEGIN
SEND "testuser"
WAIT STRING "Password:"
SEND "password"
WAIT STRING "$"
SEND "allinone"
END

In this example, the necessary connection information is already stored in the session file named “Vax.Ses”, the username is “testuser” and the password is “password”. Once successfully logged in, a command is sent to enter the host application, All-In-One in this case. In some cases, the login prompt is sent at the same time the connection is established so when the WAIT STRING command is executed in the script, the Username prompt has already been received. To account for this, we use the optional QUIET parameter of the WAIT STRING command to continue the script after waiting three seconds. Then, the SEARCH( ) function is used to verify the prompt is displayed in the session before proceeding.

An example of a login to an IBM Mainframe that has a logon banner with both prompts would look something like:

CONNECT "IBM3270"
WAIT STRING "Login:"
SEND "testuser"
SEND "password{ENTER}"

The {NEWLN} and {ENTER} are symbolic keystrokes applicable to the 3270 emulation. For more information on sending these type of characters, or ASCII control characters, see the online help of the SEND script command.

Further Development:

  • A more advanced login script may incorporate a dialog box which prompts the user to enter the user ID and password before initiating the login sequence. See the Dialog Boxes example for more information on Dialog controls.
  • This script may also include a response to a failed login message from the host, such as reporting the error and returning to the dialog box so the user can reenter the password. Determining that the host reported an error could be done by Screen Scraping where the error would be displayed, or using event triggering. See the Event Monitoring example for additional information on tracking errors and other events.
  • The script could check if the session is already open and connected, and either abort the script or reconnect and login to the session.
  • Since DCSeries is a multi-session product, it would be good practice to add the optional window handle variable to the CONNECT line, and the optional window handle arguments to each of the SEND and WAIT STRING lines.