×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to parse or capture data?

How to parse or capture data?

How to parse or capture data?

(OP)
Hi,

I'am a beginner in VBS and have zero knowledge about programming but I need to create a simple script for monitoring my customer network. Basically I will run the script in different routers..

Could any expert here guide a or share any forum thread related to my requirement for me to study? Appreciate any advise. Thank you

Below is sample code that I did for a start from reference for Internet.

##############################sample code that I did ###############################################################
crt.Screen.Send "show interfaces descriptions | match BLOCKD | no-more" & VbCr
crt.Screen.WaitForString "show interfaces descriptions | match BLOCKD | no-more"
crt.Screen.WaitForString vbcrlf

strOutput = crt.Screen.ReadString(vbcrlf)
vParse = Split(strOutput, " ")
strResultint = vParse(Lbound(vParse))

crt.Screen.WaitForString(">")
crt.Screen.Send "show interface terse | match " & strResultint & vbcr
crt.Screen.WaitForString vbcrlf

########################### output from above code #################################################
{master}
user@router1> show interfaces descriptions | match BLOCKD | no-more
ds-2/1/0:1:5 up up VPN - ABC-Office (BLOCKD)

{master}
user@router1> show interfaces terse | match ds-2/1/0:1:5
ds-2/1/0:1:5 up up
ds-2/1/0:1:5.0 up up inet 58.139.27.217/30

{master}
user@router1>


###############################################################################################################

From above script I'm able to get interface name from first command and parse to next command that router will execute that will show IP address configure for that interface.
But I'm unable to grab the IP address to move forward.


Basically what I need as below:
1) In the script, user will use specific command to match VPN Name
e.g. show interfaces descriptions | match VPNC | no-more
or maybe
e.g. show interfaces descriptions | match VPNB | no-more
2) Then, script will send the command. For the command, router will list all interfaces in the router that match the description VPNC..for example.
Different routers will probably have more or less interfaces that match the description.
3) Then, script will extract all the interfaces name
4) Proceed to send next command to find IP address using command "show interface terse <Interface name> for each interfaces found in the router that match the description in step 2
5) Do ping test to each interface/ip address by add 1 at the last octet of the IP address..i.e. IP address is 58.139.101.53. Command will ping to 58.139.101.54.


The problem I have currently is how to capture string without knowing how many row/column/array from the output and parse all that information for next command to execute.
This is because different router probably will show more or less Interface name. Example below first command will show result with 5 interfaces.

######################## Desired output from router ###########################################################

{master}
user@router> show interfaces descriptions | match VPNC | no-more
ds-2/1/0:7:1 up up IPVPN - VPNC - NO:21103
ds-2/1/0:40:1 up up IPVPN - VPNC - NO:21104
ds-2/1/0:41:1 up up IPVPN - VPNC - NO:21105
ds-2/2/0:4:1 up up IPVPN - VPNC - NO:21106
ds-2/3/0:2:1 up up IPVPN - VPNC - NO:21107

{master}
user@router> show interfaces terse ds-2/1/0:7:1
Interface Admin Link Proto Local Remote
ds-2/1/0:7:1 up up
ds-2/1/0:7:1.0 up up inet 58.139.114.105/30

{master}
user@router> ping routing-instance VPNC-h 58.139.114.106 rapid
PING 58.139.114.106 (58.139.114.106): 56 data bytes
!!!!!
--- 58.139.114.106 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 6.277/6.521/6.808/0.182 ms

{master}
user@router> show interfaces terse ds-2/1/0:40:1
Interface Admin Link Proto Local Remote
ds-2/1/0:40:1 up up
ds-2/1/0:40:1.0 up up inet 58.139.101.53/30

{master}
user@router> ping routing-instance VPNC-h 58.139.101.54 rapid
PING 58.139.101.54 (58.139.101.54): 56 data bytes
!!!!!
--- 58.139.101.54 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max/stddev = 5.211/5.447/6.169/0.363 ms


######################## Desired output from router ############################################################

RE: How to parse or capture data?

There is almost no vbscript in your code, so this forum will not help you. You should search for a forum (here or elsewhere) that corresponds to the model routers you are working with.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close