期望从输出行
中浪费“新行符号”写入变量文本如何解决这个问题?
#!/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
}
}
}
答案 0 :(得分:1)
set outdir [string trim $expect_out(buffer)]
另外,检查expect man page,有一些用户输入的例子:
stty -echo
send_user "Password: "
expect_user -re "(.*)\n"
set password $expect_out(1,string)
stty echo