私はアプライアンスにログインしてconfigをフェッチしてファイルに書き込もうとしています(私はsshキーを使用できません。実際には2つのログインがあります)。expectを使用して出力をループしてファイルに送信
問題は(私は、configファイルの最後〜100行を取得)私はこれを使用する場合、データが切り捨てられている。
...snip...
match_max 100000
set timeout 150
set output [open "outputfile.txt" "w"]
set config $expect_out(buffer)
puts $output $config
close $output
...snip...
ので、今、私はどこかで読ん提案ごとに、私は一度に1行ずつ出力をループさせるためにexpectを使用しようとしていますが、ループなしでデータを出力することはできません。ここで動作していないコードです。設定は〜700行です。
#!/usr/bin/expect
match_max 50000
spawn ssh [email protected]
expect "password"
send "password1\r"
expect "user"
send "root\r"
expect "password"
send "password2\r"
set outcome {}
set writeout [open "outputfile.txt" "w"]
expect "device"
exp_send "show running\r"
expect {
-regexp {.*}{
set outcome "${outcome}$expect_out(0,string)"
exp_continue
}
}
puts $writeout $outcome
close $writeout
expect "device"
send "exit\r"
send "yes\r"
ご協力いただければ幸いです。それ以上の情報が必要な場合はお知らせください。
ありがとうございました!