ssh가 5 개의 상자에 bash 스크립트를 실행하고, aptitude dist-upgrade -d를 실행하고, 패키지를 압축 한 다음 원본 상자로 다시 스크랩합니다.긴 스크립트없이 반복적 인 경우를 기대합니까?
모든 상자에는 동일한 암호가 있으며 모든 상자에는 dist 업그레이드에 예라고 말하기 위해 "y"입력이 필요합니다.
나의 현재, 스크립트는 다음
## Original box
expect "password"
send "Password\n"
## Box sshing to
expect "password"
send "Password\n"
expect "want to continue?"
send "y\n"
내 질문은의 반복 하중 길고 지저분 기대 어떻게해야합니까 "중복 제거"이 암호가 암호를 전송 요구되는 경우가 있으므로, 계속 프롬프트가 표시되면 y를 보냅니다.
#!/usr/bin/expect -f
set timeout -1
## This uses manualpatching.sh, used to zip up a list of the latest Debian packages
spawn ./manualpatching.sh
## BOX1
expect "password"
send "Password\n"
expect "want to continue?"
send "y\n"
## BOX2
expect "password"
send "Password\n"
expect "password"
send "Password\n"
expect "want to continue?"
send "y\n"
expect "password"
send "Password\n"
expect "connecting"
send "yes\n"
## BOX3
expect "password"
send "Password\n"
expect "password"
send "Password\n"
expect "want to continue?"
send "y\n"
expect "password"
send "Password\n"
## BOX4
expect "password"
send "Password\n"
expect "password"
send "Password\n"
expect "want to continue?"
send "y\n"
expect "password"
send "Password\n"
## BOX5
expect "password"
send "Password\n"
expect "password"
send "Password\n"
expect "want to continue?"
send "y\n"
expect "password"
send "Password\n"
## BOX6
expect "password"
send "Password\n"
expect "password"
send "Password\n"
expect "want to continue?"
send "y\n"
expect "password"
send "Password\n"
## END
expect eof
스크립트를 보여주세요! – Gaurav
자, 지금 게시를 수정합니다 –
거기에, 당신이 생각하는 것을 알려주세요. –