在期望脚本中将变量中的“新行符号”浪费掉

时间:2012-08-08 14:03:40

标签: expect

期望从输出行

中浪费“新行符号”写入变量文本

如何解决这个问题?

#!/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
    }
}
}

1 个答案:

答案 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