摘要: 如何向expect脚本里面传递参数比如下面脚本用来做ssh无密码登陆,自动输入确认yes和密码信息,用户名,密码,hostname通过参数来传递ssh.expPython代码 #!/usr/bin/expect set timeout 10 set username [lindex $argv 0] set password [lindex $argv 1] set hostname [lindex $argv 2] spawn ssh-copy-id -i .ssh/id_rsa.pub $username@$hostname expect "yes/no" send & 阅读全文
posted @ 2014-02-24 17:00 hanframe 阅读(10026) 评论(0) 推荐(1) 编辑
摘要: system "/path/to/a.sh" 阅读全文
posted @ 2014-02-24 16:40 hanframe 阅读(1448) 评论(0) 推荐(0) 编辑
摘要: 数组的声明:1)array[key]=value # array[0]=one,array[1]=two复制代码2)declare -a array # array被当作数组名复制代码3)array=( value1 value2 value3 ... )复制代码4)array=( [1]=one [2]=two [3]=three ... )复制代码5)array="one two three" # echo ${array[0|@|*]},把array变量当作数组来处理,但数组元素只有字符串本身复制代码数组的访问:1)${array[key]} # ${array[1] 阅读全文
posted @ 2014-02-24 11:27 hanframe 阅读(6260) 评论(0) 推荐(0) 编辑