InigoMontoya
IS-IT--Management
Sorry I don't mean to dump a whole block of code here but I've been trying to get this thing to work for a while now and It just keeps failing. I've narrowed it down to one last error but I can't quite figure it out. I'm hoping someone here can help.
What this section of the script is supposed to do is during a file transfer session it should be able to change the password automatically and store it in a file when prompted by the server.
I modified it a bit from when it failed and I have not tested it since. The last time it failed with a..
I changed the variable named from $pfile to $pfile2 and added a new line..
Perhaps I had to open the file for writing first. But this section seemed to have worked before w/out it.
If anyone has any ideas it would be greatly appreciated.
---------------------
What this section of the script is supposed to do is during a file transfer session it should be able to change the password automatically and store it in a file when prompted by the server.
I modified it a bit from when it failed and I have not tested it since. The last time it failed with a..
Code:
can not find channel named "file5" while executing "puts -nonewline $pfile $newpass"
I changed the variable named from $pfile to $pfile2 and added a new line..
Code:
set pfile2 [open $passfile w]
Perhaps I had to open the file for writing first. But this section seemed to have worked before w/out it.
If anyone has any ideas it would be greatly appreciated.
---------------------
Code:
expect {
"expired" {
set newpass [exec /usr/local/bin/mkpasswd -l 8 -c 6 -d 1 -s 1 -C 0]
expect "$progy>" {
send -h "chpwd\r"
}
expect "Enter old Password:" {
send -h "$pass\r"
}
expect "Enter new Password:" {
send -h "$newpass\r"
}
expect "Re-Enter new Password:" {
send -h "$newpass\r"
}
expect "Virtual user * logged in" {
set pfile2 [open $passfile w] # added this line
puts -nonewline $pfile2 $newpass
close $pfile2
}
passwd_changed "$name $newpass"
expect "$progy>" {
send -h "ascii\r"
}
expect "Type changed to Ascii" {
send -h "lcd $localdir\r"
}
expect "Local directory now" {
send -h "put $uploadfile\r"
}
expect "Transfer Complete" {
send -h "bye\r"
}
unset newpass
}
"Virtual user * logged in" {
expect "$progy>" {
send -h "ascii\r"
}
expect "Type changed to Ascii" {
send -h "lcd $localdir\r"
}
expect "Local directory now" {
send -h "put $uploadfile\r"
}
expect "Transfer Complete" {
send -h "bye\r"
}
}
}