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 <[email protected]>
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