Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-20-2018, 05:57 AM
conip conip is offline
Registered User
 
Join Date: Mar 2018
Posts: 7
Question python - multiple commands executed only in the last tab

hi,

I have one issue with executing multiple commands for multiple tabs.

All tabs are being opened sequentional in the "for" loop

when ssh or telnet session is established with SUCCESS condition I'm trying to invoke internal function "f_command(self)" but it is behaving strange

I've got each tab opened and got the MessageBox that I'm in a configure terminal but then the second command (actually the third) "end" is not sent to Screen, it is but only to the last TAB in the for loop.

Why is that?

I've forgotten to mention that Screen.Synchronous is set to True
and one strange thing: when I leave all of the TABs opened to timeout - this command "end" is being sent

Code:
previously when object class DEVICE is invoked I'm setting this property
command = "sh run | i snmp-server location\r"

class DEVICE:
	def __init__(self,DEV_IP=None,PASS=None,USER=None,FILE=None,JUMPBOX_NAME=None,CURRENT_TAB=None,COMMAND=None):
		self.DEV_IP = DEV_IP
		self.PASS = PASS
		self.USER = USER
		self.JUMPBOX_NAME = JUMPBOX_NAME
		self.FILE = FILE
		self.objTAB = CURRENT_TAB
		self.command = COMMAND

...
	def f_connect_ssh(self):
		...
		self.objTAB.Screen.Synchronous = True
		...
		self.f_command()
		...
		return



	def f_command(self):
		szPrompt = "#"
		# Wait for the command and the trailing CR to be echoed back from the remote
		# before we start capturing data... Otherwise, we'll capture the command we
		# issued, as well as the results, and in this example, we only want to
		# capture the results.
		self.objTAB.Screen.Send(self.command)
		self.objTAB.Screen.WaitForString("#",3)
		self.objTAB.Screen.Send("configure terminal\r\n")
		if self.objTAB.Screen.WaitForString("(config)#") == True:
			crt.Dialog.MessageBox("you are in CONF T") //invoked for each TAB as expected
			#self.objTAB.Activate()			//doesn't help
			self.objTAB.Screen.Send("end\r\n")
		else:
			crt.Dialog.MessageBox("you are not in CONF T")
		#self.FILE.write("\n"+szResult)
		#crt.Dialog.MessageBox(szResult)
		return

Last edited by conip; 03-20-2018 at 06:53 AM.
Reply With Quote
 

Tags
command , multiple , python , send , tabs


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 07:46 AM.