Shell学习笔记

chsh 改变shell配置
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

Monthly Archives

Pages

Powered by Movable Type 7.7.2

About this Entry

This page contains a single entry by Cnangel published on August 9, 2006 11:35 AM.

干地质很累,不是件好事。 was the previous entry in this blog.

辣椒的学问(二) is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.