不曉得有人遇到嗎?
原如碼截錄如下:
exp_send "/usr/bin/md5sum ${folder1}/${file1}.${temp_suffix} | /bin/cut -d ' ' -f 1\r"
set timeout 90
expect {
-re "md5sum .+${temp_suffix}.+f 1\[\r\n]+(\[0-9a-f]\{32\})\[\r\n].+${os_prompt}" {
set md5sum1 "$expect_out(1,string)"
}
上述程式碼主要是取出 md5sum 的 md5
但是,小弟觀察 buffer 變化時,發現 Redhat 6.4 x64 的 expect 好像會加上 \r
就好像 terminal 有邊界 ex. 80x24, 會在超過 80個字元後面換到下一行
buffer 如下:
expect: does " /usr/bin/md5sum /XXXX/XXXXXXX/XXXXXX/XXXX/XXXXXXXXX/XXX/20 \r15-08-31/YYYYYYY+YYYYYYYYYY_2015-08-31_16-30-54.tar.gz.TEMP | /bin/cut -d ' ' -f \r 1\r\n2017588475f6ed603dba55259a342cc7\r\n\u001b]0;root@test-01:~\u0007[root@test-01 ~]# " (spawn_id exp4) match regular expression "md5sum .+TEMP.+f 1[\r\n]+([0-9a-f]{32})[\r\n].+root@.+ .+].*#"? Gate "md5sum *TEMP*f 1*root@* *]*#"? gate=no
"md5sum .+md5sum: .+: No such file or directory"? Gate "md5sum *md5sum: *: No such file or directory"? gate=no
"md5sum .+md5sum: .+: : Is a directory"? Gate "md5sum *md5sum: *: : Is a directory"? gate=no
根據之前的經驗,什麼時候會加 \r 好像沒有什麼規則,所以只好將判斷規則簡化
不過,總覺得這是個問題...
另外,我是用 linux ssh 到 另外一台 linux 執行上述程式
會不會是 ssh 本身 terminal 設定的問題?
不知道有哪位大德可以給小的一點建議
謝謝