Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-02-2013, 02:34 PM
kgaudineer kgaudineer is offline
Registered User
 
Join Date: Jan 2011
Posts: 15
Question Dialog Box Hanging Script.

Greetings,

I have been reading post for several days and I believe I have a script that fits my needs for config backups. (Thanks to everyone for your helpul hints) however I keep running into one problem, and I have been unable to resolve it.

Here is the scenario: A tech is out in the field and is either replacing a switch or installing a new one. For what ever reason the tech does not configure the SSH properly. This does end in a connection error. But when running my script the 'On Error Resume Next' error handling is interrupted because there is a dialog box that appears before the script error. The dialog box is for an authentication error. The dialog box has a 'Skip' and and 'OK' button that needs to be interacted with before the script error is shown and and we can move on to the next host.

My question is.... Is there a way to handle the dialog box so that my script can continue to run?
Reply With Quote
  #2  
Old 12-02-2013, 02:53 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,352
Hello kgaudineer,

Is the connection being done via the script?

If so, the Connect() and ConnectInTab() methods include parameters that will help you to accomplish the objective:

Quote:
The Connect method takes a parameter (True or False) that determines whether or not the script should wait for the connection to fully authenticate before continuing. For instance, the connect call in the examples below will wait until the connection has been fully authenticated before returning and allowing the script to execute the error check just below the connect call. This parameter only applies to SSH1 and SSH2 connections. Whereas, passing False would allow the error check to execute before the connection has a chance to finish. You will probably want to use False only in cases where you want to script the logon process for the session you are attempting to connect to. The default value for this parameter is True.

The Connect method also takes an optional parameter (True or False) that specifies whether or not to suppress pop-up messages. This parameter defaults to False (don't suppress).

This information (and examples) is found in the Scripting / Script Objects Reference / Session Object topic in SecureCRT's Help file.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 12-03-2013, 05:02 AM
kgaudineer kgaudineer is offline
Registered User
 
Join Date: Jan 2011
Posts: 15
Question The Pop-Up still Happens

Thanks for the reply. I read through the section you had mentioned but the pop-up is still happening and the script is still pauding when the pop-up is occuring. I have added a portion of my script to show how I am making the connect. I have tried using True, True, / False, True / False, False / True, False but still no luck. I will also try to upload or put a screen shot of the dialog box that is popping up,,,,,,

#$language = "VBScript"
#$interface = "1.0"

'crt.Screen.Synchronous = True

Sub Main

Dim vHosts(100)
vHosts(0) = "10.24.11.240"
vHosts(1) = "10.24.12.240"
vHosts(2) = "10.24.13.240"
vHosts(3) = "10.24.33.240"
vHosts(4) = "10.24.21.240"
vHosts(5) = "10.24.22.240"
vHosts(6) = "10.24.23.240"
vHosts(7) = "10.24.30.240"
vHosts(8) = "10.24.31.240"
vHosts(9) = "10.24.32.240"
vHosts(10) = "10.24.14.240"
vHosts(11) = "10.24.34.240"
vHosts(12) = "10.24.35.240"

Dim Cliuser
Dim Clipass


Cliuser = InputBox("Please enter the username")
Clipass = InputBox("Please enter the password")

For Each strHost In vHosts
If strHost = "" Then Exit For

' Make sure we are disconnected before attempting a connection
If crt.Session.Connected Then
Do

crt.Session.Disconnect
Loop While crt.Session.Connected
End If

crt.Screen.Synchronous = True
' I am building a connect command below this line to pass to the switch
cmd = "/SSH2 /L " & Cliuser & " /PASSWORD " & Clipass & " /C 3DES /M MD5 " & strHost

On Error Resume Next
' Now I will use the connect command built above
crt.Session.Connect cmd, False, True
nError = Err.Number
strErr = Err.Description
On Error Goto 0
if nError <> 0 Then
'strLogfile = "C:\CRT-Temp\Log-CRTtmp-%Y.%M.%D.txt" Keeping just for syntax reasons...
MsgBox "Error connecting: " & strErr
Else

' Do some work on the host here like backup the startup config

End If

Next


End Sub


The attachment is the dialog box that keeps popping up
Attached Images
File Type: jpg popup.jpg (15.1 KB, 244 views)
Reply With Quote
  #4  
Old 12-03-2013, 12:08 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,352
Hi kgaudineer,

Thanks for the clarification.

One thing you will need to do is enable Display logon prompts in terminal window. This is available in v6.1 and later in the Connection / Logon Actions category of Session Options.

Since you are making ad hoc connections, you will want to change this in the Default Session.

Then you should be able to handle the authentication failure in your script.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 12-04-2013, 10:18 AM
kgaudineer kgaudineer is offline
Registered User
 
Join Date: Jan 2011
Posts: 15
Red face That Was The Fix...

Thank You for the quick response

That was the fix. I have recently upgraded from SecureCRT v6x to Version 7.1.3 (build 378).

Thanks again all is working well....
Reply With Quote
  #6  
Old 12-04-2013, 10:43 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,352
Hi kgaudineer,

Great! I am glad to hear the issue is resolved.

Thanks for posting!
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 04:42 AM.