Shell common statement
for statement
format
for NUM in 1 2 3
for NUM in {1..3}
for NUM in `seq 1 3` 或者 for NUM in `seq 1 2 10`
do
done
Examples
With seq way
while statement
while 条件
do
Done
Examples
Because the conditions have been established, so i have been executed in
until usage
format and while the same time, until the condition is false is executed
The condition is true, is not performed
The if statement
if
then
elif
then
。。。
else
fi
case statement
case
word1)
action1
;;
word2)
action2
;;
........
*)
action_last
esac
Case and IF
Case is named, is performed only once, if every time judge
expect
expect an automatic response command for interactive commands executed automatically
spawn is in the monitoring program expect, after its interaction issues raised by running the command monitors
send answers to questions sent to the interactive command
"\ r" denotes carriage
exp_continue indicate when the problem is not continue to answer the following questions in the presence of
expect eof complete answer questions marked exit expect the environment
interact to answer question mark left in the finished interactive interface
to define variables set NAME [lindex $ argv n] , starting from 0 count
Expect first need to download the software
Example: ssh connection automatically
Script statements controller
exit n 脚本退出,退出值为n
break 退出当前循环
continue 提前结束循环内部的命令,但不终止循环