• Support
  • Articles
  • Resources
  • Products

Asistance in TTLeditor scripting for automated CLI provision

Moderator: boris

3 postsPage 1 of 1

aalakhras
Newbie

Posts:
2
Joined: Tue Nov 11, 2014 11:10 am
by aalakhras » Tue Nov 11, 2014 11:30 am
I am trying to automate a mass provisioning on a device ( similar to a
switch / router) and the thing is that i need to have this done by
scripting using ttl editor and call the macro fro teraterm.

I will take a chunk as an example that I want to execute on teraterm cli

Configure
interface ont-13-2-31
grant 1 2000 IPTV
grant 2 1000 VOIP
grant 3 2000 Internet
grant 4 1000 FA_IM_IR_GL
grant 5 1000 Outdoor_Internet
grant 6 1000 IPCAMs
sdv 456
sdvprofile SDV_ALL
end

there are two variables ( ont-13-2-31, sdv 456 )
the variable that change ont-13-2-31 --> ( 13 can be any number from 1 to 20, 2 can any be any number from 1 to 8, and 31 can be any number from 1 to 64) , sdv also is a number between 255 and 4096 ,( example here uses 456 )

the grand and sdv commands are executed under ont-x-y-z command

. starting point is ont-1-1-1, ont-1-1-2,...ont-1-1-64 , then ont-1-2-1, ont-1-2-2,...ont-1-2-64, till ont-1-8-64, then ont-2-1-1,... and so on so the last will be ont-20-8-64..


please advise how to do this on ttl editor to be called to teraterm
rgaiken
Beginner

Posts:
42
Joined: Mon Apr 02, 2012 2:53 pm
by rgaiken » Tue Nov 11, 2014 6:49 pm
It's been well over a year since I've touched TT scripting (got a new job where we don't use TT). But I'll try to get you pointed in the right direction. I don't have this installed, so I can't test the code to see if it'll work:

You'll want three nested for loops, if I'm reading your post correctly:

Code: Select all

  1. x=0
  2. y=0
  3. z=0
  4. for x 1 20
  5.     for y 1 8
  6.         for z 1 64
  7.             call runCommands
  8.         next
  9.     next
  10. next


Code: Select all

  1. :runCommands
  2. ; Set this to whatever your command prompt is on your system
  3. cmdPrompt='>'
  4. ; Creates the "Interface ont-x-y-z command"
  5. sprintf2 ontCmd "interface ont-%d-%d-%d" x y z
  6. sendln ontCmd
  7. wait cmdPrompt
  8. sendln 'Grant 1 2000 IPTV'
  9. wait cmdPrompt
  10. ; Continue this for the rest of the commands
  11. return


If you have any questions about any of the commands I used, look here and here first
If one of my posts helped you out, do me a favor:
Next time anyone asks you for help, go out of your way to help them.

Thanks!
aalakhras
Newbie

Posts:
2
Joined: Tue Nov 11, 2014 11:10 am
by aalakhras » Wed Nov 12, 2014 8:32 am
Massive thanks for this . I applied this on a switch that doesnt support such commands, just to see if the commands execute or not and the if is working and it does :) put low value for x and y just to see if it works and get appropriate outputs. I really appreciate that

Code: Select all

  1.  
  2. x=0
  3. y=0
  4. z=0
  5. for x 8 9
  6.     for y 1 2
  7.         for z 1 2
  8.             call runCommands
  9.         next
  10.     next
  11. next
  12. :runCommands
  13. cmdPrompt='ProCurve Switch 2600-8-PWR#'
  14. cmdPrompt2='ProCurve Switch 2600-8-PWR(config)#'
  15. sendln 'config'
  16. sprintf2 ontCmd "interface ont-%d-%d-%d" x y z
  17. sendln ontcmd
  18. wait cmdPrompt2
  19. sendln 'grant 1 2000 IPTV'
  20. wait cmdPrompt2
  21. sendln 'grant 2 1000 VOIP'
  22. wait cmdPrompt2
  23. sendln 'grant 3 3000 Internet'
  24. wait cmdPrompt2
  25. sendln 'grant 4 1000 FA_IM_IR_GL'
  26. wait cmdPrompt2
  27. sendln 'grant 5 1000 Outdoor_Internet'
  28. wait cmdPrompt2
  29. sendln 'grant 6 1000 IPCAMS'
  30. wait cmdPrompt2
  31. sendln 'sdvprofile SDV_ALL'
  32. wait cmdPrompt2
  33. sendln 'end'
  34. return
  35.  
Display posts from previous:
Sort by:

3 postsPage 1 of 1

Users browsing this forum: No registered users