Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #16  
Old 12-12-2018, 08:59 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,652
Hi myawan,

The results don't make sense because it should just hang forever if the data expected by the WaitForString() is not received (first time through loop).

You aren't interacting in any way when the script runs, are you? (e.g. Pressing ENTER?)

This code block should be changed:
Code:
        ' 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
Instead, it should look like this:
Code:
        ' Make sure we are disconnected before attempting a connection
        If crt.Session.Connected Then
            crt.Session.Disconnect
            Do
                crt.Sleep(100)
            Loop While crt.Session.Connected
        End If
Also, does Default Session maybe have a logon script configured and enabled in the Connection / Logon Actions category?
__________________
Thanks,
--Brenda

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

Last edited by bgagnon; 12-12-2018 at 11:13 AM. Reason: Additional from jdev
Reply With Quote
  #17  
Old 12-12-2018, 11:37 PM
myawan myawan is offline
Registered User
 
Join Date: Dec 2018
Posts: 8
Quote:
Originally Posted by bgagnon View Post
Hi myawan,

The results don't make sense because it should just hang forever if the data expected by the WaitForString() is not received (first time through loop).

You aren't interacting in any way when the script runs, are you? (e.g. Pressing ENTER?)
Hi bgagnon, thanks for the reply.
No I am not interacting during the script.

Quote:
This code block should be changed:
Code:
        ' 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
Instead, it should look like this:
Code:
        ' Make sure we are disconnected before attempting a connection
        If crt.Session.Connected Then
            crt.Session.Disconnect
            Do
                crt.Sleep(100)
            Loop While crt.Session.Connected
        End If
Also, does Default Session maybe have a logon script configured and enabled in the Connection / Logon Actions category?
I changed the code but still output is the same.
No, there is no logon script configured.
Reply With Quote
  #18  
Old 12-13-2018, 05:29 AM
myawan myawan is offline
Registered User
 
Join Date: Dec 2018
Posts: 8
Secondly is there any option to telnet all hosts in separate tabs and run command set without worrying about disconnecting session before the next.
Reply With Quote
  #19  
Old 12-13-2018, 09:41 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,652
Hi myawan,

For the original issue, you will need to configure Default Session to log trace options output. This is an INI change:
  • Locate config folder path in General / Configuration Paths category of Global Options

  • Close all instances of SecureCRT

  • Locate Default.ini in the Sessions subfolder of the config folder

  • Change:
D:"Trace Level"=00000000
to:
D:"Trace Level"=00000001
Then, launch SecureCRT and configure logging in Default Session (Options / Edit Default Session). Enable Start log upon connect and Raw log and configure a log filename and location. Include %h%m%s%t as part of the log filename so we can distinguish between the two log files. Then run your script and two log files with timestamps as part of the filename should be saved to the specified location.

Since trace options can contain sensitive information, feel free to send them as an attachment via email to support@vandyke.com. Please reference "Attn Brenda - Forum Thread #10957" in the subject line.

NOTICE: The requested troubleshooting data may include sensitive information (usernames, passwords, publicly-accessible host names or IP addresses, etc.).

Please redact sensitive information that would not be appropriate for email communication prior to sending the requested information.

If there is sensitive information that must be conveyed in order to provide a complete picture of the scenario you're facing, please let us know and we will set up a secure upload mechanism that can be used.

To answer the second inquiry, yes, you can do that by iterating over the tabs. See Scripting / Script Objects Reference (Tab Object). You'll also need to use the GetTabCount() method available to the Application Object. For the iteration, you could just use a For/Next loop.

Is this for a different objective? Because if you are thinking of tackling the original task another way, we probably should not invest any more time in troubleshooting your script.
__________________
Thanks,
--Brenda

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

Last edited by bgagnon; 12-13-2018 at 11:05 AM.
Reply With Quote
  #20  
Old 12-16-2018, 12:18 AM
myawan myawan is offline
Registered User
 
Join Date: Dec 2018
Posts: 8
Yes, basically I am trying to accomplish same task using Tab method. But for that I need your help regarding modification of my code.
Reply With Quote
  #21  
Old 12-16-2018, 06:55 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,652
Hi mayawan,

Since presently the errors seem to occur within the execution of the multiple commands, I think we are still going to need to troubleshoot that. So I need the logs/trace previously requested.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #22  
Old 12-18-2018, 12:32 AM
myawan myawan is offline
Registered User
 
Join Date: Dec 2018
Posts: 8
Hi Brenda,

Logs are attached.
Attached Files
File Type: zip Log Files.zip (1.3 KB, 28 views)

Last edited by myawan; 12-18-2018 at 12:36 AM.
Reply With Quote
  #23  
Old 12-18-2018, 11:41 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,652
Hi myawan,

I think the graphic below explains the issue and resolution.

Attached Images
File Type: png DeviceSendsPromptsTwice(Forum10957_myawan).png (257.2 KB, 93 views)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #24  
Old 12-20-2018, 01:12 AM
myawan myawan is offline
Registered User
 
Join Date: Dec 2018
Posts: 8
Thanks a lot Brenda, I'll modify my code accordingly and share the test results here.

Update: Tested and working fine. Thanks a lot. You are a hero!

Last edited by myawan; 12-20-2018 at 01:46 AM.
Reply With Quote
  #25  
Old 12-20-2018, 06:36 AM
myawan myawan is offline
Registered User
 
Join Date: Dec 2018
Posts: 8
Hi Brenda,

I have modified my code a little bit more to read IPs from a text file. I took help from sample code on these forums.
Can you please go through the code to see what are the problems as this code doesn't seem to execute at all? There must have been some very obvious mistakes.

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

Dim g_strHostsFile

g_strHostsFile    = "\\tsclient\D\Script\hosts.txt"
Const ForReading   = 1

Dim g_strHost

Dim g_bUseExistingSessions
g_bUseExistingSessions = True

Dim vHosts()

Dim nHostCount


Sub Main
 
For nIndex = 0 To nHostCount - 1

     g_strHost = vHosts(nIndex)
     If g_strHost = "" Then Exit For
 	
' Make sure we are disconnected before attempting a connection 

 If crt.Session.Connected Then
 	crt.Session.Disconnect
	Do
		crt.Sleep(1000)
	
	Loop While crt.Session.Connected
    End If

' Connect to the next host

 	crt.Session.Connect "/telnet " & strHost
	crt.Screen.Synchronous = True
	crt.Screen.WaitForString "Password: "
	crt.Screen.Send "ericsson" & chr(13)
	crt.Screen.WaitForString ">"
	crt.Screen.Send "en" & chr(13)
	crt.Screen.WaitForString "Password: "
	crt.Screen.Send "ericsson" & chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.Send "config" & chr(13)
	crt.Screen.WaitForString "(config)#"
	crt.Screen.Send "ftp server name remotehost address 10.215.134.10" & chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.WaitForString "#"
	crt.Screen.Send "ftp active configuration-report remotehost" & chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.WaitForString "#"
	crt.Screen.Send "exit" & chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.WaitForString "#"
	crt.Screen.Send "write" & chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.WaitForString "#"
	crt.Screen.Send "generate-report report-data-content rl equipment ethernet inventory ne" & chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.WaitForString "#"
	crt.Screen.Send "exit" & chr(13)

Next
crt.Screen.Synchronous = False

End Sub
Reply With Quote
  #26  
Old 12-20-2018, 08:11 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,652
Hi myawan,

The graphic posted indicated you would need to "double up" the WaitForString() lines starting with the first prompt after password, so you have missed one.
Code:
	crt.Screen.WaitForString "Password: "
	crt.Screen.Send "[redacted]" & chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.WaitForString "#"    ' <-----Missing
	crt.Screen.Send "config" & chr(13)
If you still see no progress, is Cancel available in the Script menu? If so, and you choose it, what line does it indicate the script is hanging on?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #27  
Old 12-22-2018, 11:26 PM
myawan myawan is offline
Registered User
 
Join Date: Dec 2018
Posts: 8
Thanks Brenda for the reply.
May be I was not clear in my statement. Actually I applied your recommendations (doubling the wait commands) and the script worked fine. Thanks for that.

The code I posted above is after modification to allow reading IPs from a text file. After this modification, the script isn't working.
Can you please check the code related to reading IPs from a text file?
Reply With Quote
  #28  
Old 12-24-2018, 10:15 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,652
Hi myawan,

You have declared this variable, but you have never given it a value:

Dim nHostCount

A better approach is to read the entire hosts file into an array and then you can use a For loop to iterate over the array. Similar to what's illustrated starting on line 237 of the VBScript example script here.
__________________
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 08:05 PM.