linux expect if判断
linux下expect的简单使用 - 桦沐 - 博客园
expect语法参考:
1. expect中的判断语句:
if { condition } {
# do your things
} elseif {
# do your things
} else {
# do your things
}
expect中没有小括号(),所有的if/else, while, for的条件全部使用大括号{}, 并且{ 与左边要有空格,否则会报错。另,else 不能单独占一行,否则会报错。
2. 字符串比较
if { "$node" == "apple" } {
puts "apple"
} elseif { "$node" == "other" } {
puts "invalid name"
exit 70
} else {
puts "asd"
}
对比string,使用==表示相等, !=标示不相等。