Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-02-2018, 05:14 PM
bstedh bstedh is offline
Registered User
 
Join Date: Jan 2018
Posts: 41
Capture output witch requires space to continue

I am trying to capture the output of a command in a microwave modem. unlike cisco I can not set the terminal length to 0 and the output contains text that matches the prompt. I have to use vbCrLf to identify end of lines but how do I capture all the output without it stalling? Here is a section of my script as it is now but doesn't work. I know why it isn't working. I need a different way of capturing this output.

Code:
Case "Config"
				command = Replace(dwConfig,"_"," ")
				crt.Screen.Send command & vbCr
				crt.Screen.WaitforString vbCrLf
				Do
					Output = crt.Screen.WaitforStrings (vbCrLf,"<<<<< Press any key to continue >>>>>","NAK",3)
					Select Case Output
						Case 0
							
						Case 1
							Outt = crt.Screen.Readstring (vbCr)
						Case 2
							crt.Screen.Send " "
						Case 3
							Out = "NAK"
							Exit Do
					End Select
					Out = Out & vbCr & Outt
					MsgBox Out
				Loop
				f0Clipboard(Out)
				Out = HTMLformat(Out,2)
Here is a sample of what I am trying to capture. A space has to be entered at every break and the beginning and end prompts are "->"

Code:
1. get radio band
Currently selected Radio Band :fcc11_1_30_R5

Radio Bands Available in the system:

freqNone                       etsi11_1_56_530_R5            
etsi11_1_56_490_R5             fcc_itu11_1_40_R5             
etsi11_1_40_490_R5             etsi11_1_40_530_R5            
itu11_1_40_R5                  fcc11_1_30_R5                 
ic11_1_30_R5                   etsi11_1_28_530_R5            
etsi11_1_28_490_R5             ic11_1_20_R5                  
itu11_1_20_R5                  etsi_itu11_1_14_R5            
itu11_1_14_R5                  

->2. get frequency bank

fcc11_1_30_R5
txHigh FREQUENCIES(Selected)

Index      TX RF           RX RF          
1'        11215000        10715000       
2'        11245000        10755000       
3'        11285000        10795000       
4'        11325000        10835000       
5'        11365000        10875000       
6'        11405000        10915000       

All Frequency in kHz

->3. get programmed frequency

Index     TX RF (kHz)     RX RF (kHz)    
3'        11285000        10795000       

->4. get system mode
Current system mode is :hy30_209_256qam
System modes available in the system :
cw_test              hy30_39_qpsk         hy30_92_16qam       
hy30_118_32qam       hy30_144_64qam       hy30_170_128qam     
hy30_196_256qam      hy30_209_256qam     


These system modes are not applicable when haam is on.
->5. get system speed
Licensed speed set to   :500 Mbps
Current speed set to    :222 Mbps
System mode set to      :hy30_209_256qam

->6. get qos
qos is  :on

->7. get cos default value

Default cos value for packet without vlan tag is as follows :

 port name     default cos value
 ---------     -----------------
 p1            0
 p2            0


->8. get cos type
CoS type is :cos_vlan.
Available cos types in the system are :
cos_vlan   cos_qinq_itag   cos_qinq_otag   cos_dscp   cos_mplsexp

->

<<<<< Press any key to continue >>>>>
9. get cos queue mapping
Enter valid port name.
Reply With Quote
  #2  
Old 01-02-2018, 05:21 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi bstedh,

This sounds like an interesting problem. Are you needing to manipulate the data at all or are you wanting to simply capture it? Would writing the data to a log file be an option?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 01-02-2018, 05:34 PM
bstedh bstedh is offline
Registered User
 
Join Date: Jan 2018
Posts: 41
I might do that as I was going to have a popup asking if the user wants to save the output to a file. Generally all the commands in my script automatically go into the clipboard. My first try was to just wait for string <<<<press space>>> but I would loose the last portion of the output and couldn't get the time out to work.

I would like to manipulate the output however but I can do that in a seperate vbs script to make the output usable to directly configure a new modem. I wish we could call another script from inside a running script. =]
Reply With Quote
  #4  
Old 01-02-2018, 05:54 PM
bstedh bstedh is offline
Registered User
 
Join Date: Jan 2018
Posts: 41
Two steps forward one step back...

Logging the output will work very well, THANK YOU.

Now I find the my output also contains "NAK" witch is used to identify that the command didn't work if it comes up right away so It quits prematurely. Thats Ok though I can fix that. I will then be able to just read the output back in to put it into the clipboard.
Reply With Quote
  #5  
Old 01-02-2018, 05:55 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi bstedh,

I'm reviewing options that may be available for capturing your data. Is there something that we could use as an indication that we should stop capturing?

Do you only have to interact with the output when <<<<< Press any key to continue >>>>> appears or are there other times key presses need to happen?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #6  
Old 01-02-2018, 06:10 PM
bstedh bstedh is offline
Registered User
 
Join Date: Jan 2018
Posts: 41
The only interaction needed is the space to continue.

The only indication we are at the end is the prompt "->" but that is also found throughout the output. Unfortunately different FW versions will have different output so I can't rely on specific outputs. Otherwise I would be continually changing the script. Logging is working perfectly. I am just trying to refresh my memory on working with files now to get the info back into the script. I have so many things setup in functions that I forget how to do some of the basics. =]

I was just about to lookup objShell.SpecialFolders to figure out how to point to the log file to the desktop.
Reply With Quote
  #7  
Old 01-02-2018, 06:23 PM
bstedh bstedh is offline
Registered User
 
Join Date: Jan 2018
Posts: 41
Ok, Got it working good. All I have to do is read the info back into the clipboard and everything is working as I wanted it to.

Here is the code I have now.

Code:
			Case "Config"
				Set objShell = CreateObject("WScript.Shell")
				strDesktop = objShell.SpecialFolders("Desktop")
				Dim logfile
				logfile = strDesktop & "\Horizonconfig.log"
				crt.Session.LogFileName = logfile
				crt.Session.Log True
				command = Replace(dwConfig,"_"," ")
				crt.Screen.Send command & vbCr
				crt.Screen.WaitforString vbCrLf
				Do
					Output = crt.Screen.WaitforStrings ("<<<<< Press any key to continue >>>>>",3)
					Select Case Output
						Case 0
							crt.Session.Log False
							Exit Do
						Case 1
							crt.Screen.Send " "
					End Select
				Loop
				f0Clipboard(Out)
				Out = HTMLformat(Out,2)
			Case "RESET"
Reply With Quote
  #8  
Old 01-03-2018, 09:23 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi bstedh,

I'm glad to hear that you found a solution that works for you.

Please don't hesitate to reach out if we can help with a different perspective in the future.

I'm sure you've had luck getting the contents of the file to the clipboard but if not I've included some sample code below.
Code:
Set objShell = CreateObject("WScript.Shell")
strDesktop = objShell.SpecialFolders("Desktop")
logfile = strDesktop & "\Horizonconfig.log"

Set g_fso = CreateObject("Scripting.FileSystemObject")
Set objFile = g_fso.OpenTextFile(logfile, 1)
strFileContents = objFile.ReadAll
objFile.Close

crt.Clipboard.Text = strFileContents
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #9  
Old 01-04-2018, 07:30 AM
bstedh bstedh is offline
Registered User
 
Join Date: Jan 2018
Posts: 41
Thanks for the reply, I already have a function in my script for populating the clipboard. And yes almost exactly the same as your sample I just put the file into a variable and called the function.

Code:
f0Clipboard(Output)

Function f0Clipboard(input)
	crt.Clipboard.Format = "CF_TEXT"
	crt.Clipboard.Text = input
End Function
Reply With Quote
  #10  
Old 01-04-2018, 09:20 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi bstedh,

Looks like you're off to the races. Please don't hesitate to reach out if you have any other questions.

Have a great 2018.
__________________
Thanks,
--Eric

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

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 06:29 PM.