
원격 서버에 로그인하여 netcat 명령(이 명령 포함)의 출력을 파일에 쓰려고 합니다. 하지만 이건 쓰는 게 아니다. 내가 무엇을 놓치고 있나요?
#!/usr/bin/expect -f
set user [lindex $argv 0]
stty -echo
send_user "Password: "
expect_user -re "(.*)\n"
set passwd $expect_out(1,string)
send_user "\n"
stty echo
set output [open "outputfile.txt" "a+"]
spawn ssh [email protected]
expect {
"yes/no" {
send "yes\r"
exp_continue
}
}
expect -exact "$user@mydomain's password: "
sleep 2
send -- "$passwd\r"
sleep 5
expect -re $
puts $output "myhost ---> destinatin"
send "nc -zv -w 1 XX.XX.XX.XX 443\n"
sleep 10
expect "*$"
set outcome $expect_out(buffer)
send "\r"
puts $output $outcome
send "logout\r"
close $output
expect eof
exit 0