วันอาทิตย์ที่ 10 กุมภาพันธ์ พ.ศ. 2562

expect ssh to output file

#!/usr/bin/expect -f
set user "root"
set password "toor"
set ip "10.0.0.88"

spawn ssh $user@$ip
expect "password:"
sleep 1
send "$password\r"

expect ">" {send "racadm getsysinfo\r"} >/home/ssh.txt
expect ">" {send "exit\r"}
set output [open "outputfile.txt" "a+"]
set outcome $expect_out(buffer)
puts $output $outcome
close $output
expect EOF


ไม่มีความคิดเห็น:

แสดงความคิดเห็น