Hi All,

Please some help me understand the script provided by Rashmi.
The script is given below (within Rashmi's reply)

--- In [email protected], Rashmi Pawar <rashmeepa...@...> wrote:
>
> Hi Please find attached file...
> 
> 
> Hi,
> 
> Please find attached file tocahange password on all linux machines...Hope
> this is helpful to you
> see the "usage" in the script...
> ---------- Forwarded message ----------
> From: doorsofperception82 <anupn...@...>
> Date: Sun, Nov 22, 2009 at 8:45 AM
> Subject: [LinuxVadaPav] change password tool
> To: [email protected]
> 
> 
> 
> 
> Hi
> 
> I have around 100 Linux servers for which I want to change password.
> I cant find a way for doing that!
> Some one please guide me
> 
> 
> 
>   ----------
> 
> #!/usr/bin/expect
> #
> #
> # usage: runcmd <command> <password>
> #
> # NB: be sure to surround the command with double quotes
> # if the command string is more than 1 word
> #
> 
> set timeout 30
> set fid [open /root/utilz/scripts/hosts r]
> set contents [read -nonewline $fid]
> close $fid
> 
> set cmd [lindex $argv 0]
> set password [lindex $argv 1]
> set newpass [lindex $argv 2]
> foreach host [split $contents "\n"] {
>     spawn ssh -l root $host
>     expect {
>         "assword:" {
>             send -- "$password\r"
>         }
>         "you sure you want to continue connecting" {
>             send -- "yes\r"
>             expect "assword:"
>         send -- "$password\r"
>         }
>     }
>     expect "#"
>     send -- "$cmd\r"
>     expect "assword:"
>     send "$newpass\r"
>     expect "assword:"
>     send "$newpass\r"
>     expect "#"
>     send -- "exit\r"
> 
> 
> [Non-text portions of this message have been removed]
>


Reply via email to