Password=PasswordBox("Enter your login password","Create Startup Script Wizard: Password ")
End If
resp = Password + "<Enter>"
GetResponse = GR_PASSWORD
Case 2
resp = "<Enter>" ' CR
GetResponse = GR_ENTER
Case 3 ' Custom entry
resp = CCString(getuser.customtext) + "<Enter>"
Case 4 ' Ignore input -- continue
GetResponse = GR_IGNORE
Case 5 ' All done with input
GetResponse = GR_DONE
Case 6 ' All done with input and close telnet session
GetResponse = GR_DONE_TELNET
End Select
End Function
Sub Main()
Begin Dialog weldlg 281, 159, "TNVTPlus Script Wizard: Welcome", .Welcome
PushButton 167, 129, 40, 14, "&Next >", .next1
CancelButton 214, 129, 40, 14, .cancel1
Text 7, 3, 256, 45, "This wizard helps you create a TNVTPlus script. For example, a script can connect to a network host automatically and do work on that host."
Text 7, 27, 256, 45, "The wizard prompts you for information about automatic login and the commands you want to execute on the network host."
Text 7, 51, 256, 45, "When you finish creating the TNVTPlus script, a file is created in your default sessions directory with an .ote extension. Double click on the .ote file to run it."
Begin Dialog timerdlg 281, 159, "TNVTPlus Script Wizard: Set the Time Between Prompts", .SetTimer
PushButton 167, 129, 40, 14, "&Next >", .next2
Text 10, 38, 226, 44, "Type the maximum amount of time in seconds you want the TNVTPlus script to wait for a response from the network host. TIP: The maximum timeout value is 300 seconds."
PushButton 125, 129, 40, 14, "< &Back", .back2
CancelButton 214, 129, 40, 14, .cancel2
Text 10, 10, 230, 25, "The TNVTPlus script sends messages to the network host and waits for a response. The amount of time that the program waits is called a Timeout."
Begin Dialog hostpromptdlg 281, 159, "TNVTPlus Script Wizard: Set hostname and host prompt", .SetPrompt
PushButton 167, 129, 40, 14, "&Next >", .next4
PushButton 125, 129, 40, 14, "< &Back", .back4
CancelButton 214, 129, 40, 14, .cancel4
Text 5, 5, 269, 31, "Each network host has a name and an Internet Protocol (IP) address. The name is often called a host or hostname. The Host prompt chararacter(s) helps the wizard identify when the network host is waiting for user input. "
Begin Dialog finishdlg 281, 159, "TNVTPlus Script Wizard: Finish"
PushButton 167, 129, 40, 14, "&Finish >", .next3
PushButton 125, 129, 40, 14, "< &Back", .back3
CancelButton 214, 129, 40, 14, .cancel3
Text 7, 6, 247, 45, "The wizard has enough information to begin a TNVTPlus session. You will be prompted to respond to the program running on the network host."
Text 7, 26, 247, 45, "Your responses are recorded in the .ote file. You can run the .ote file later to repeat the same commands."
Text 7, 90, 180, 25, "Click Finish to begin the TNVTPlus session."
End Dialog
Dim hidlg as weldlg
Dim timedlg as timerdlg
Dim hostdlg as hostpromptdlg
Dim finaldlg as finishdlg
Dim logdlg as logindlg
Dim idx as Integer, createobj As Integer
Dim RetStatus As Integer
Dim cansave As Integer
Dim filenum As Integer
Dim res as Integer
'Initialize
createobj = FALSE
' Set up hostname and port
port = "Telnet"
' initialize variables
waittime = "30"
hostpromptchar = ">"
hostname = ""
Username = ""
Password = ""
SavePassword = 1
LoginPrompt = "login:"
PasswordPrompt = "password:"
wVisible = 1
tn_numtargets = 0
wCreateSte = 1
wPlaybackVis = 1
' create the tnvt object so that the GetUserName function can be accessed during the wizard
If createobj = FALSE Then
set Telnet = CreateObject("FTPSTNVTPlus.Application")
createobj = TRUE
End If
' invoke the startup screen
Hello:
WelcomeRc = ""
res = Dialog(hidlg)
Select Case WelcomeRc
Case "cancel"
GoTo CancelTeach
End Select
' Next> was chosen. Continue with the timer dialog.
Timeit:
TimerReturn = ""
res = Dialog(timedlg)
Select Case TimerReturn
Case "cancel"
GoTo CancelTeach
Case "back"
GoTo Hello
End Select
' Ask user for the typical host prompt to look for: '
hostprompt:
HostReturn = ""
res = Dialog(hostdlg)
Select Case HostReturn
Case "cancel"
GoTo CancelTeach
Case "back"
GoTo Timeit
End Select
If Len(hostpromptchar) <> 0 Then
tn_prompt(tn_numprompts) = hostpromptchar
tn_suggest(tn_numprompts) = 3
tn_numprompts = tn_numprompts + 1
End If
Logit:
LoginRc = ""
Password = ""
' create a telnet object and obtain the username if possible
Username = Telnet.GetUserName
res = Dialog(logdlg)
Select Case LoginRc
Case "cancel"
GoTo CancelTeach
Case "back"
GoTo hostprompt
End Select
' if the user is not creating an .ste file OR not saving the password, then let the remote host request the password!
If SavePassword <> 0 AND wCreateSte <> 0 Then
Password=PasswordBox("Enter your login password","TNVTPlus Script Wizard: Password ")
If Password = "" Then
GoTo Logit
End If
End If
EndWizard:
WRc = ""
res = Dialog(finaldlg)
Select Case res
Case 0
GoTo CancelTeach
Case 2
Goto Logit
End Select
' create a session and login:
set Session = Telnet.NewSessionFile
Session.Hostname = hostname
Session.Port = port
Session.Username = Username
Session.UsernamePrompt = LoginPrompt
' make sure the user is allowed to save the password in the session file
Session.SavePassword = 1
cansave = Session.SavePassword
If cansave <> 0 Then
Session.Password = Password
End If
if Password <> "" OR wCreateSte = 1 Then
Session.PasswordPrompt = PasswordPrompt
End If
res = Session.Connect
If res > 10000 Then
res = MsgBox ("Telnet Connection failed. Would you like to try another host?", 4, "Create Wizard Script: cannot connect")
if res = 6 Then
GoTo hostprompt
Else
GoTo CancelTeach
End If
End If
Telnet.Visible = wVisible
InitVars
read_next:
gl_linbuf = ""
glres = GetLine(VAL(waittime))
Select Case glres
Case GL_CANCEL
GoTo retry
Case GL_TIMOUT
res = MsgBox("Timeout and no data returned",5,"Create Wizard Script: Timeout")