Masha Misery
Masha Misery

Reputation: 69

waste "new line symbol" in variable in expect script

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

Answers (1)

glenn jackman
glenn jackman

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

Related Questions