View Single Post
Old 08-25-2008, 08:55 AM
darkoth darkoth is offline
Registered User
Join Date: Jun 2007
Posts: 29
Hrm. I'm getting an "unexpected 'next". I'm not all that versed with VB as of yet. FYI. I'm using Version 6.1 of SecureCRT

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

crt.Screen.Synchronous = True

Sub Main
	crt.Screen.Send "cat server_list.txt" & vbcr
	vServerList = Split(crt.Screen.ReadString("]$"), vbcr)

	For Each szHost in vServerList
    		crt.Screen.Send "ssh " & szHost & vbcr
        		szResults = Crt.Screen.WaitforStrings("Are you sure...", "Password:", 60) = 1
        		Select Case szResult
            			Case 1
                			crt.Screen.Send "yes" & vbcr
            			Case 2
                			szPassword = crt.dialog.prompt("Please enter your password", "Password", "", True)
                			crt.Screen.Send szPassword & vbcr
					exit do
            			Case else
                			MsgBox "We timed out"
        		end select

	crt.Screen.Send "su -" & vbcr
    	crt.Screen.WaitForString "Password:"
    	szRootPassword = crt.dialog.Prompt("Please enter the root password: ", "Root Password", "", True)
    	crt.Screen.Send szRootPassword & vbcr
    	crt.Screen.Send "passwd root" & vbcr
        	szNewPassword = crt.dialog.prompt("Please enter the new password: ", "New Password", "", True)
        	szConfirmPassword = crt.dialog.prompt("Please confirm your new password: ", "Confirm Password", "", True)

        	if szNewPassword <> szConfirmPassword then
            		MsgBox "User did not provide matching passwords"
        	end if

    		While szNewPassword <> szConfirmPassword
    			crt.screen.Send szNewPassword & vbcr
    			crt.Screen.WaitForString "Re-enter new Password:"
    			crt.Screen.Send szNewPassword & vbcr
    			crt.Screen.WaitForString "passwd: password successfully changed for root"
    			crt.Screen.Send "exit" & vbcr
End Sub
Also, what would be a good book to learn VBScript?

Last edited by darkoth; 08-25-2008 at 09:04 AM.
Reply With Quote