2014-10-30 4 views
0

아래 스크립트의 문제점을 누구든지 도울 수 있습니까? 암호가 성공적으로 변경되었지만 암호는 이전 암호로 유지됩니다. 이 스크립트를 실행하여 ssh를 사용하여 전문가 모드로 직접 로그인하는 검사 점 SPLAT 방화벽 전문가 암호를 변경합니다.ssh를 사용하여 암호를 변경하는 스크립트가 필요합니다.

#!/usr/bin/expect 
set username admin 
set oldpass sam$$$ 
set newpass abc.123 

spawn ssh -l $username 192.168.1.10 

expect "assword:" 
send "$oldpass\r" 
expect "# " 
sleep 1 
send "passwd\r" 
expect "Enter new expert password:" 
send "$newpass\r" 
expect "Enter new expert password (again):" 
send "$newpass\r" 
expect eof" 
expect "# " 
send "exit\n" 


[[email protected] ~]$ ./test.sh 
spawn ssh -l admin 192.168.1.10 
[email protected]'s password: 
Last login: Thu Oct 30 18:41:52 2014 from 192.168.1.5 
[[email protected]]# passwd 
Enter new expert password: 
Enter new expert password (again): 
Expert password has been changed 
+0

스크립트가 정상적으로 보입니다. '기대'때문에 문제가 보이지 않습니다. 너가 놓친 다른 것이 있을지도 모른다. – Dinesh

답변

0

확인해보십시오, 저에게 도움이되었습니다.

#!/usr/bin/expect 
set timeout 20 
set user user2 
set password abc123 
set new bac234qwe.1 
set ip localhost 
spawn -noecho ssh -q -o StrictHostKeychecking=no "$user\@$ip" "passwd" 
expect "assword:" 
send "$password\r" 
expect "*UNIX password:" 
send "$password\r" 
expect "New password: " 
send "$new\r" 
expect "Retype new password:" 
send "$new\r" 
+0

[admin @ localhost ~] $ ./test14.sh ./test14.sh : 8 행 : 생성 : 명령을 찾을 수 없음 "assword :"파일을 읽을 수 없음 : 해당 파일 또는 디렉토리가 없음 ./test14.sh : 줄 10 : 보내기 : 명령을 찾을 수 없습니다. "* UNIX 암호 :": 해당 파일 또는 디렉터리를 읽을 수 없습니다. ./test14.sh : 줄 12 : 보내기 : 명령을 찾을 수 없음 파일을 읽을 수 없습니다. 암호 : ": 해당 파일이나 디렉토리가 없습니다. ./test14.sh : 줄 14 : 보내기 : 명령을 찾을 수 없습니다. "새 암호 다시 입력 : ": 해당 파일이나 디렉토리가 없습니다. ./test14.sh : line 16 : send : 명령을 찾을 수 없습니다. [admin @ localhost ~] $ –

+0

'which expect' 명령의 결과를 제공하십시오. –

+0

Hey Shriharsha, –

관련 문제