Reputation: 69
expect write to variable text with waste "new line symbol" from output line
how to solve this problem?
#!/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
}
}
}
Upvotes: 0
Views: 1942
Reputation: 246827
set outdir [string trim $expect_out(buffer)]
Also, check the expect man page, there are a few examples of user entry:
stty -echo
send_user "Password: "
expect_user -re "(.*)\n"
set password $expect_out(1,string)
stty echo
Upvotes: 1