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 09-04-2018, 04:00 PM
mohamed_23_7 mohamed_23_7 is offline
Registered User
 
Join Date: Sep 2018
Posts: 3
Smile securecrt & python

Hello every one ,

i need to get this number "371" from the show command and be noted that the (olt-13-5) is variable . i used crt.screen.WaitForString and crt.screen.ReadString but i cannot get it . if i used slice it will not accurate as there is variable (olt-13-5) that can be increased or decreased with one index



DABAAH-G01E-MT-EG-x# show free gem olt-13-5
371
DABAAH-G01E-MT-EG-x#
Reply With Quote
  #2  
Old 09-04-2018, 04:11 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 526
Hi mohamed_23_7,

That sounds like an interesting problem.

What version of SecureCRT are you running? What Operating System are you running SecureCRT on?

How does the "show free gem olt-13-5" command get sent? Are you typing it manually or is it being sent by the script?
__________________
Thanks,
--Eric

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

Last edited by ekoranyi; 09-05-2018 at 08:40 AM.
Reply With Quote
  #3  
Old 09-04-2018, 05:17 PM
mohamed_23_7 mohamed_23_7 is offline
Registered User
 
Join Date: Sep 2018
Posts: 3
securecrt & python

Dear ekoranyi,

i don not think that the problem in securecrt version or windows as i run the same lib " crt.screen.WaitForString and crt.screen.ReadString" in the same code.i made this command to be send by script and i need output to put it in another script . kindly check my code below .. the last command is my show command .

Code:
import re
import sys
import time

def main():

    objTab = crt.GetScriptTab()
    objTab.Screen.Synchronous = True
    objTab.Screen.IgnoreEscape = True
    All=crt.Dialog.Prompt("Please Enter the Ont Location ","ont", "" ,True)
    Location=crt.Dialog.Prompt("Please Enter the OLT Location ","OLT", "" ,True)
    serial=crt.Dialog.Prompt("Please Enter the Ont serial","Serial","",True)
    crt.Screen.Send("telnet "+"10.42.73.82"+ "\r" )
    crt.Screen.WaitForString ("user:")
    crt.Screen.Send("TVTadmin"+"\r")
    crt.Screen.WaitForString ("pass:")
    crt.Screen.Send("p4$$word"+"\r")
    crt.Screen.WaitForString("-x%")
    crt.Screen.Send("enable"+"\r")
    crt.Screen.WaitForString("-x#")
    crt.Screen.Send("remove"+" ont"+" ont-"+ All + "\r\n")
    crt.Screen.Send("init"+" ont"+" ont-"+ All + "\r\n")
    crt.Screen.Send("delete"+" ont"+" ont-"+ All + "\r\n")

    screen1 = crt.Screen.WaitForString("-x#")
    screen2 = crt.Screen.WaitForString("-x#")
    screen3 = crt.Screen.WaitForString("-x#")



    if screen1==True:	
    	crt.Screen.Send("edit" + " port" +" olt-" + Location + "" + " oos" + "\r\n")
    	crt.Screen.Send("enter" + " port" + " ont-" + Location + "" + " oos" + "\r\n")
    	crt.Screen.Send("show" + " ont" + " all" + " learned" + "\r\n")

    if screen2==True:
    	crt.Screen.Send("config" + " \r\n" +"int"+" ont-"+ All + "" + "\r\n")
    	crt.Screen.Send("ven " + "id"+" ERSN"+"" + "\r\n")
    	crt.Screen.Send("ven "+"serial "+ serial + "" + "\r\n")
    	crt.Screen.Send("exit" + " \r\n")
    	crt.Screen.Send("restore " +"ont "+"ont-"+ All +" \r\n")
    	crt.Screen.Send("show " +"ont "+"ont-"+ All +" state"+"\r\n")

    if screen3==True:
    	crt.Screen.Send("config" + " \r\n" +"inter"+" ont-"+ All + "" + "\r\n")
    	crt.Screen.Send("grant 1 " +"2048"+" 0"+" 6144"+" MGMT" + "\r\n")
    	crt.Screen.Send("grant 2 " +"2048"+" 0"+" 6144"+" VOIP" + "\r\n")
    	crt.Screen.Send("grant 3 " +"6144"+" 0"+" 24576"+" IPTV" + "\r\n")
    	crt.Screen.Send("grant 4 " +"12288"+" 0"+" 49152"+" HSIs" + "\r\n")
    	crt.Screen.Send("grant 5 " +"2048"+" 0"+" 2048"+" VIRTUAL" + "\r\n")
    	crt.Screen.Send("exit" + " \r\n")	
    	crt.Screen.Send("show " +"free"+" gem "+ All +"\r\n")


main()

Last edited by jdev; 09-04-2018 at 06:11 PM. Reason: wrap code in [code] blocks to preserve indentation and never include literal passwords
Reply With Quote
  #4  
Old 09-05-2018, 09:20 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 526
Hi mohamed_23_7,

If you are sending the "show free gem olt-13-5" command via the script there are some patterns that should help you capture the needed data.

First send your command and wait for the command to be echoed back.

Code:
crt.Screen.Send("show free gem " + All + "\r\n")
crt.Screen.WaitForString("show free gem " + All + "\r\n")
Then do the ReadString and configure the ReadString to stop capturing when your prompt appears.

Code:
strResult = crt.Screen.ReadString("DABAAH-G01E-MT-EG-x#")
Does this help you capture the needed data?
__________________
Thanks,
--Eric

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

Last edited by ekoranyi; 09-05-2018 at 09:23 AM.
Reply With Quote
  #5  
Old 09-05-2018, 11:25 AM
mohamed_23_7 mohamed_23_7 is offline
Registered User
 
Join Date: Sep 2018
Posts: 3
securecrt & python

yes, it helps . many thanks to you my dear .
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 08:36 AM.