chsh 改变shell配置
expect 在机器之间进行交互性操作
在expect提示时,美元$符号导致问题解决如下:
expect 在机器之间进行交互性操作
在expect提示时,美元$符号导致问题解决如下:
1 set timeout 300 | 1 #!/bin/bash
2 set host [lindex $argv 0] | 2 #Create By Cuci
3 set cmd [lindex $argv 1] | 3 #Create Date At 2007.08.06
4 spawn ssh $host | 4 #Function Backup Data to Server
5 expect "\\$" | 5
6 send "$cmd\r" | 6 host_n=1
7 expect "\\$" | 7 hosts=(rsdev2.corp.cnb)
8 send "exit\r" | 8 n=0
9 | 9 cmd=$1
~ | 10 while [ $n -lt $host_n ]
~ | 11 do
~ | 12 host=${hosts[n]}
~ | 13 echo "===================================="
~ | 14 expect -f backup.tcl "$host" "$cmd"
~ | 15 echo "===================================="
~ | 16 n=`expr $n + 1`
~ | 17 done