Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Script to Add/Remove a CDP/DSC using SecureCRT 1

Status
Not open for further replies.
Apr 20, 2009
1
US
Hi All,

Does anyone have a basic script to add or remove a DSC from a CDP table ?
Any assistance would be appreciated !

Joe
 
Well, there isn't really a CDP Table. There is an entry for each CDP #. What exactly is it you are trying to do?
 
You can try these. Not very refined but they work for me.
Code:
# $language = "VBScript"
# $interface = "1.0"

' Script to remove DSC's from an M1/CS1000 switch.
' Uses comma-delimited file C:\temp\cdp_out.csv which has a single column of DSC's that are to be removed
' You need to be in LD 87 to start.

Dim g_objTab, g_objLogFile
Set g_objTab = crt.GetScriptTab
Set g_objLogFile = CreateObject("Scripting.FileSystemObject")
' Define the amount of time (milliseconds) that should be introduced as
' a delay between each line being sent to the remote host.
g_nDelay = 500

Const ForAppending = 8
Const ForReading = 1

Sub main

  ' Open a file
  Dim fso, f

  Set fso = CreateObject("Scripting.FileSystemObject")

  Set f = fso.OpenTextFile("c:\temp\cdp_out.csv", ForReading, 0)

  Dim line, params
  g_objTab.screen.Synchronous = True

	crt.Screen.Send chr(13)

  Do Until f.AtEndOfStream
     bDidOne = False
    line = f.Readline
    params = Split( line, "," )
    Do Until bDidOne
         Select Case This_Prompt
           Case "REQ"   Xmit "OUT"
           Case "CUST"  Xmit "0"
           Case "FEAT"  Xmit "CDP"
           Case "TYPE"  Xmit "DSC"
           Case "DSC"   Xmit params(0)
                        bDidOne = True
           Case Else     Xmit ""
         End Select
    Loop
  Loop
	crt.Screen.WaitForCursor(2)
	Xmit ""
  g_objTab.screen.Synchronous = False

End Sub

Function This_Prompt
' The "This_Prompt" function returns the PBX prompt at the current cursor position

  ' Make sure the cursor has stopped moving
   Do
     bCursorMoved = crt.Screen.WaitForCursor(1)
   Loop Until bCursorMoved = False

   screenrow = g_objTab.screen.CurrentRow
   This_Prompt = Trim(g_objTab.screen.Get(screenrow, 1, screenrow, 20))

End Function

'-----------------------------------------------------------------------------
Function Xmit(sCmd)
' The "Xmit" function replaces the CRT Send command.
' It simplifies sending commands to the PBX by adding
' the carriage return and pacing the command input.

  g_objTab.screen.Send sCmd & chr(13)
End Function
Code:
# $language = "VBScript"
# $interface = "1.0"

' Script to add DSC's to an M1/CS1000 switch.
' Uses comma-delimited file C:\temp\cdp_new.csv with this format
' DSC,FLEN,RLI
' All other prompts are skipped.
' You need to be in LD 87 to start

Dim g_objTab, g_objLogFile
Set g_objTab = crt.GetScriptTab
Set g_objLogFile = CreateObject("Scripting.FileSystemObject")
' Define the amount of time (milliseconds) that should be introduced as
' a delay between each line being sent to the remote host.
g_nDelay = 500

Const ForAppending = 8
Const ForReading = 1

Sub main

  Dim fso, f
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.OpenTextFile("c:\temp\cdp_new.csv", ForReading, 0)

  Dim line, params
'  g_objTab.screen.Synchronous = True

'	crt.Screen.Send chr(13)

  Do Until f.AtEndOfStream
     bDidOne = False
    line = f.Readline
    params = Split( line, "," )
    Do Until bDidOne
         Select Case This_Prompt
           Case "REQ"   Xmit "NEW"
           Case "CUST"  Xmit "0"
           Case "FEAT"  Xmit "CDP"
           Case "TYPE"  Xmit "DSC"
           Case "DSC"   Xmit params(0)
           Case "FLEN"  Xmit params(1)
           Case "DSP"  	Xmit ""
           Case "RLI"  	Xmit params(2)
           Case "NPA"  	Xmit ""
           Case "NXX"   Xmit ""
                        bDidOne = True
           Case Else    Xmit ""
         End Select
    Loop
  Loop
	crt.Screen.WaitForCursor(1)
	Xmit ""
   g_objTab.screen.Synchronous = False

End Sub

Function This_Prompt
' The "This_Prompt" function returns the PBX prompt at the current cursor position

  ' Make sure the cursor has stopped moving
   Do
     bCursorMoved = crt.Screen.WaitForCursor(1)
   Loop Until bCursorMoved = False

   screenrow = g_objTab.screen.CurrentRow
   This_Prompt = Trim(g_objTab.screen.Get(screenrow, 1, screenrow, 20))

End Function

'-----------------------------------------------------------------------------
Function Xmit(sCmd)
' The "Xmit" function replaces the CRT Send command.
' It simplifies sending commands to the PBX by adding
' the carriage return and pacing the command input.

  g_objTab.screen.Send sCmd & chr(13)
End Function
 
My procomm plus scripts are on the FAQ section.

If you need the software or more assistance, then contact me via the link below at the bottom.

Procomm_Plus_CDP_script_zym28t.png


Firebird Scrambler

Nortel & Avaya Meridian 1 / Succession & BCM / Norstar Programmer

Website = linkedin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top