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 06-30-2020, 02:55 AM
js11o9 js11o9 is offline
Registered User
 
Join Date: Jun 2020
Posts: 4
Waitforstring doesn't work not solved yet

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

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
	crt.Screen.Send chr(13) & chr(13) & chr(13)
	
	dd = crt.Screen.CurrentRow 

	dd2 = crt.Screen.get(dd,1,dd,50)


	dim result
		 
	host_name = trim(dd2)
	result = crt.Screen.WaitForString (host_name)


	'crt.Screen.Send host_name & chr(13)
	crt.Sleep 100
	
	'아래부터 로그 수집 과정'
	
crt.Screen.Send "show clock" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "ter monitor" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show int desc | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show ip int bri | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show inter | grep CRC | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send " show ip route su | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)
	
crt.Screen.Send "show ip ospf nei | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show ip ospf 1 nei | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show ip ospf 2 nei | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show ip bgp su | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show arp su | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send " show proce cpu su | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show proc cpu mana | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show proce mem | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show mem | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show ip ro 0.0.0.0/0 | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show ver | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show run | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show int | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show env all | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show syst b | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)

crt.Screen.Send "show logg | no" & chr(13)
result = crt.Screen.WaitForString (host_name)
crt.Screen.Send chr(13)
result = crt.Screen.WaitForString (host_name)


End Sub

i want to make this script work well
but there are some problems

after I operate above script for 8 times or more

some commands are just skipped.
can not get all of above commands

so.......what i have to do make them right??

i used secureCRT

Last edited by cboyack; 06-30-2020 at 07:17 AM. Reason: Please make sure to use the [CODE] and [/CODE] tags to properly identify code strings
Reply With Quote
  #2  
Old 06-30-2020, 08:48 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,357
Hi js11o9,

The hostname is already present the first time you wait for it:

Code:
    host_name = trim(dd2)
    result = crt.Screen.WaitForString (host_name)
That means the above is actually not in effect until you run 'show clock' and for each iteration the script gets farther out of sync.

If you remove the sleep and other items creating the issue, what are the results?

Code:
Sub Main
    crt.Screen.Send chr(13) & chr(13) & chr(13)
    dd = crt.Screen.CurrentRow 
    dd2 = crt.Screen.get(dd,1,dd,50)
    dim result
    host_name = trim(dd2)
    crt.Screen.Send "show clock" & chr(13)

continue .
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 07-01-2020, 12:15 AM
js11o9 js11o9 is offline
Registered User
 
Join Date: Jun 2020
Posts: 4
thanks but not solved

I tried with your code

Code:
Sub Main
    crt.Screen.Send chr(13) & chr(13) & chr(13)
    dd = crt.Screen.CurrentRow 
    dd2 = crt.Screen.get(dd,1,dd,50)
    dim result
    host_name = trim(dd2)
    crt.Screen.Send "show clock" & chr(13)
…
continue ….

but... command 'show ip route su | no ' is skipped ( 9 try 8 skipped)
and sometimes chr(13) is skipped too

baud rate is 115200

Last edited by cboyack; 07-01-2020 at 07:11 AM. Reason: Please use the [CODE] and [/CODE] tags to properly show code in these forums
Reply With Quote
  #4  
Old 07-01-2020, 07:44 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,357
Hi js11o9,

Unfortunately there is no easy way to discover where the script gets out of sync. You will just need to sprinkle in message boxes that display results and look for any that do not display the expected result.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 07-06-2020, 11:08 PM
js11o9 js11o9 is offline
Registered User
 
Join Date: Jun 2020
Posts: 4
solved!

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

crt.Screen.Synchronous = True

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main





dd = crt.Screen.CurrentRow
dd2 = crt.Screen.get(dd,1,dd,50)

host_name = trim(dd2)


crt.Screen.Send "show clock" & chr(13)
crt.Screen.WaitForString host_name


crt.Screen.Send "ter monitor" & chr(13)
crt.Screen.WaitForString host_name


crt.Screen.Send "show int desc | no" & chr(13)
crt.Screen.WaitForString host_name


crt.Screen.Send "show ip int bri | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show inter | grep CRC | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send " show ip route su | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show ip ospf nei | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show ip ospf 1 nei | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show ip ospf 2 nei | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show ip bgp su | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show arp su | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send " show proce cpu su | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show proc cpu mana | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show proce mem | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show mem | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show ip ro 0.0.0.0/0 | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show ver | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show run | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show int | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show env all | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show syst b | no" & chr(13)
crt.Screen.WaitForString host_name

crt.Screen.Send "show logg | no" & chr(13)
crt.Screen.WaitForString host_name

End Sub



above is the code that works correctly.
delete crt.Screen.Send & chr(13)& chr(13)& chr(13)

maybe this Send command make all code unsynchronized...

and what if i want to use 3 chr(13) ??
what should I waitforstring next 3 chr(13) ?

and thank you for helping me
Reply With Quote
  #6  
Old 07-07-2020, 07:40 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,357
Hi js11o9,
Quote:
and what if i want to use 3 chr(13) ??
what should I waitforstring next 3 chr(13) ?
I guess my question would be why?

Under what circumstances do you need to send just ENTER (multiple times)?

But to answer the question, yes.

As outlined in the Scripting Essentials guide (section 4.2, specifically Avoid "Missing" Data with Screen.Synchronous = True), every Send() should have a corresponding WaitForString() in order to keep the script in sync.
__________________
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:13 AM.