0

期望从输出行写入带有浪费“换行符”的变量文本

如何解决这个问题呢?

#!/usr/local/bin/expect -f

set timeout 30
puts "enter the path to output folder"
while 1 { 
expect {
    "*\n" {
        set outdir $expect_out(buffer)
       break
    } timeout {
        puts "warning: timed out"
        set outdir $DEFAULT_OUT
        break
    }
}
}
4

1 回答 1

1
set outdir [string trim $expect_out(buffer)]

另外,查看expect 手册页,有一些用户输入示例:

 stty -echo
 send_user "Password: "
 expect_user -re "(.*)\n"
 set password $expect_out(1,string)
 stty echo
于 2012-08-08T16:29:32.467 回答