View Single Post
  #1  
Old 04-02-2008, 09:00 AM
darkoth darkoth is offline
Registered User
 
Join Date: Jun 2007
Posts: 29
Need help with sending command to multiple tabs

I'm trying to create a script to send a command to multiple tabs.

In this instance, I'm trying to issue a sudo -s command

If "password:" is found return the password, if "#" is found then continue. I'm new at this and am trying to figure out where I'm going wrong. Thanks!

Code:
#$language = "VBScript"
#$interface = "1.0"

crt.Screen.Synchronous = True

Sub Main()

	For nIndex = 1 to crt.GetTabCount
		Set objCurrentTab = crt.GetTab(nIndex)
		objCurrentTab.Activate
		if objCurrentTab.Session.Connected = True then
			crt.Sleep 500
			objCurrentTab.Screen.Send "/usr/local/bin/sudo -s" & chr(13)

			Dim result;
			result = objCurrentTab.screen.WaitForString("Password:" , 5)

			if result = "Password:" 
				objCurrentTab.Screen.Send "test123" & chr(13)
			else continue;
			crt.Sleep 1000
		end if
	Next

	' turn off synchronous mode for normal input processing
	crt.Screen.Synchronous = False
End Sub
Reply With Quote