View Single Post
  #2  
Old 08-22-2008, 06:29 PM
jjh jjh is offline
VanDyke Customer Support
 
Join Date: Feb 2004
Posts: 815
Hello darkoth.

Here is some information that shows you how you might accomplish your goals with scripting:

Code:
'~ 1.) Execute command -
'~ cat server_list.txt 

crt.Screen.Synchronous = True
crt.Screen.Send "cat server_list.txt" & vbcr


'~ 2.) Read in the list of server names and store them. 

vServerList = Split(crt.Screen.ReadString("]$"), vbcr)


'~ 3.) ssh first server name

For Each szHost in vServerList

    crt.Screen.Send "ssh " & szHost & vbcr

    '~ 4.) If this comes up on the screen
    '~ "Are you sure you want to continue connecting (yes/no)?"
    '~ Then send yes else continue 

    '~ 5.) This will display
    '~ "Password: "
    '~ send pop up - "Please enter your password"
    '~ store password and send it to the terminal. 

    Do
        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
    Loop
   

    '~ 6.) Run command:
    '~ su -
    
    crt.Screen.Send "su -" & vbcr
    

    '~ 7.) Wait for "Password: " and send to screen - Please enter root password. 
    '~ store root password. 

    crt.Screen.WaitForString "Password:"
    szRootPassword = crt.dialog.Prompt("Please enter the root password: ", "Root Password", "", True)
    crt.Screen.Send szRootPassword & vbcr

    '~ 8.) Next run command
    '~ passwd root 
    
    crt.Screen.Send "passwd root" & vbcr

    '~ 9.) Wait for "New Password: "

    '~ 10.) send pop up with screen asking for a new root password and store it. 

    Do

        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

    '~ 11.) Send new password 
    crt.screen.Send szNewPassword & vbcr

    '~ 12.) Wait for "Re-enter new Password: " and send password again. 
    crt.Screen.WaitForString "Re-enter new Password:"
    crt.Screen.Send szNewPassword & vbcr

    '~ 13.) Wait for "passwd: password successfully changed for root" 
    crt.Screen.WaitForString "passwd: password successfully changed for root"

    '~ 14.) exit server and return to next server in list and then repeat steps 4-13 until the list has expired. 
    crt.Screen.Send "exit" & vbcr
    
Next
Does this look like it will help you?

Thank you

JJH
Reply With Quote