View Single Post
Old 03-20-2018, 06:57 AM
conip conip is offline
Registered User
Join Date: Mar 2018
Posts: 7
Question python - multiple commands executed only in the last tab


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

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.FILE = FILE
		self.objTAB = CURRENT_TAB
		self.command = COMMAND

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

	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("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
			crt.Dialog.MessageBox("you are not in CONF T")

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