home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
pc3270sa.zip
/
vbscript
/
logon.mac
< prev
Wrap
INI File
|
2002-02-28
|
6KB
|
151 lines
[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=Sample to start a session and logon
[PCOMM SCRIPT SOURCE]
' This sample will start an emulator session and logon to VM.
' This sample is written assuming the following sequence of host screens
' MSG10 screen
' a logon screen containing
' "USERID ===> " for the user id input
' "PASSWORD ===> " for the password input
connection_name = "Z" ' short name of the session to be created
profile_name = "RUI" ' profile that is used to start new session
host_name = "HOST" ' the host name
user_id = "USERID" ' user id
password = "PASSWORD" ' user's password
' much of the logic of this sample is based on loops waiting for some
' asynchronous event.
' i = 0
' While (NOT asynchronous_condition) And i < number_of_retries
' i = i + 1
' autECLSession.autECLPS.Wait(miliseconds_to_wait)
' Wend
' where asynchronous_condition is just some boolean asynchronous event
' The following two variables control the
' number of retries and the number of miliseconds between each retry.
number_of_retries = 1000
miliseconds_to_wait = 500
' determine if there is already a connection with this name
set dis_object = autECLConnMgr.autECLConnList.FindConnectionByName(connection_name)
' No connection with this name
If dis_object is NOTHING Then
' start a connection
autECLConnMgr.StartConnection "profile=" & profile_name & " connname=" & connection_name
' must do a refresh to update the connection list
autECLConnMgr.autECLConnList.Refresh
' find the connection that was just created
set dis_object = autECLConnMgr.autECLConnList.FindConnectionByName(connection_name)
' set to use that connection
autECLSession.SetConnectionByName(connection_name)
i = 0
While (dis_object is NOTHING) And i < number_of_retries
i = i + 1
autECLSession.autECLPS.Wait(miliseconds_to_wait)
' must do a refresh to update the connection list
autECLConnMgr.autECLConnList.Refresh
' find the connection that was just created
set dis_object = autECLConnMgr.autECLConnList.FindConnectionByName(connection_name)
Wend
' if the connection does not exist then end
If dis_object is NOTHING Then
MsgBox("error creating session " & connection_name)
' The connection exists
Else
' make sure session is started
i = 0
While (NOT autECLSession.Started) And i < number_of_retries
i = i + 1
autECLSession.autECLPS.Wait(miliseconds_to_wait)
Wend
' session is started
If autECLSession.Started Then
' start communication for the session and wait for the connection to be established
If autECLSession.CommStarted Then
Else
autECLSession.StartCommunication
autECLSession.autECLPS.Wait(miliseconds_to_wait)
i = 0
While (NOT autECLSession.CommStarted) And i < number_of_retries
i = i + 1
autECLSession.autECLPS.Wait(miliseconds_to_wait)
Wend
End If
If autECLSession.CommStarted Then
' The connection is established
' proceed to logon screen
autECLSession.autECLPS.SendKeys(host_name& "[Enter]")
' wait for the logon screen to appear
found_string = autECLSession.autECLPS.SearchText("RUNNING " & host_name)
i = 0
While (NOT found_string) And i < number_of_retries
i = i + 1
autECLSession.autECLPS.Wait(miliseconds_to_wait)
found_string = autECLSession.autECLPS.SearchText("RUNNING "& host_name)
Wend
If found_string Then
' the logon screen is present
' have to refresh the presentation space
autECLSession.autECLPS.autECLFieldList.Refresh
' find where to input the user id
set userid_field = autECLSession.autECLPS.autECLFieldList.FindFieldByText("USERID ===> ", 1, 1, 1)
If userid_field is NOTHING then
' could not find the place for userid
' Text not found
MsgBox ("userid Not Found")
Else
' input the user id
autECLSession.autECLPS.SetText user_id,userid_field.EndRow, userid_field.EndCol+2
' find the place to put the password
set password_field = autECLSession.autECLPS.autECLFieldList.FindFieldByText("PASSWORD ===> ", 1, 1, 1)
If password_field is NOTHING then
' count not find place for password
MsgBox ("password Not Found")
Else
' input password and send ENTER
autECLSession.autECLPS.SetText password,password_field.EndRow, password_field.EndCol+2
autECLSession.autECLPS.SendKeys("[Enter]")
End If
End If
Else
MsgBox(" could not connect to " & host_name & i)
End If
Else
MsgBox(" The connection could not be established ")
End If
Else
MsgBox(" not started "& i)
End If
End If
' The connection already exists
Else
MsgBox("Session " & connection_name & " already exists ")
End If