linux expect的用法
来源:互联网 发布:黑暗网络进入方法 编辑:程序博客网 时间:2024/06/07 02:16
#!/usr/bin/expect
set hostip [lindex $argv 0]
set fbasepasswd [lindex $argv 1]
set pubpasswd [lindex $argv 2]
set homspasswd [lindex $argv 3]
#puts stdout $hostip
#puts stdout $fbasepasswd
#puts stdout $pubpasswd
#puts stdout $homspasswd
if { $argc != 4 } {
puts stderr "cres update fail"
exit 1
}
#备份fbase
spawn ssh fbase@$hostip
expect {
"yes/no" { send "yes\r";exp_continue }
"fbase@$hostip's password:" { send "$fbasepasswd\r" }
}
expect "]*"
send "rm -rf fbase\r"
send "mkdir /home/fbase/fbase2_backup\r"
send "cp -avx /home/fbase/workspace /home/fbase/fbase2_backup/\$(date +%Y%m%d%H%S)/\r"
send "cp -avx /home/fbase/appcom /home/fbase/fbase2_backup/\$(date +%Y%m%d%H%S)/\r"
send "cp -avx /home/fbase/install_fbase.sh /home/fbase/fbase2_backup/\$(date +%Y%m%d%H%S)/\r"
send "exit\r"
expect eof
#上传文件
#上传fbase目录
spawn scp -r /root/fbase/ fbase@$hostip:/home/fbase
expect {
"yes/no" { send "yes\r";exp_continue }
"fbase@$hostip's password:" { send "$fbasepasswd\r" }
}
send "exit\r"
expect eof
#更新fbase
spawn ssh fbase@$hostip
expect {
"yes/no" { send "yes\r";exp_continue }
"fbase@$hostip's password:" { send "$fbasepasswd\r" }
}
expect "]*"
send "rm -rf ~/workspace\r"
send "rm -rf ~/appcom\r"
send "mv -f ~/fbase/* ~/\r"
send "chmod +x install_fbase.sh\r"
send "./install_fbase.sh\r"
expect "Y/N"
send "source .bash_profile\r"
send "exit\r"
expect eof
set hostip [lindex $argv 0]
set fbasepasswd [lindex $argv 1]
set pubpasswd [lindex $argv 2]
set homspasswd [lindex $argv 3]
#puts stdout $hostip
#puts stdout $fbasepasswd
#puts stdout $pubpasswd
#puts stdout $homspasswd
if { $argc != 4 } {
puts stderr "cres update fail"
exit 1
}
#备份fbase
spawn ssh fbase@$hostip
expect {
"yes/no" { send "yes\r";exp_continue }
"fbase@$hostip's password:" { send "$fbasepasswd\r" }
}
expect "]*"
send "rm -rf fbase\r"
send "mkdir /home/fbase/fbase2_backup\r"
send "cp -avx /home/fbase/workspace /home/fbase/fbase2_backup/\$(date +%Y%m%d%H%S)/\r"
send "cp -avx /home/fbase/appcom /home/fbase/fbase2_backup/\$(date +%Y%m%d%H%S)/\r"
send "cp -avx /home/fbase/install_fbase.sh /home/fbase/fbase2_backup/\$(date +%Y%m%d%H%S)/\r"
send "exit\r"
expect eof
#上传文件
#上传fbase目录
spawn scp -r /root/fbase/ fbase@$hostip:/home/fbase
expect {
"yes/no" { send "yes\r";exp_continue }
"fbase@$hostip's password:" { send "$fbasepasswd\r" }
}
send "exit\r"
expect eof
#更新fbase
spawn ssh fbase@$hostip
expect {
"yes/no" { send "yes\r";exp_continue }
"fbase@$hostip's password:" { send "$fbasepasswd\r" }
}
expect "]*"
send "rm -rf ~/workspace\r"
send "rm -rf ~/appcom\r"
send "mv -f ~/fbase/* ~/\r"
send "chmod +x install_fbase.sh\r"
send "./install_fbase.sh\r"
expect "Y/N"
send "y\r"
send "source .bash_profile\r"
send "exit\r"
expect eof
0 0
- linux expect的用法
- linux expect spawn的用法
- linux expect spawn的用法
- expect spawn、linux expect 用法
- expect spawn、linux expect 用法
- expect spawn、linux expect 用法
- expect spawn、linux expect 用法
- expect spawn、linux expect 用法
- linux expect 用法小记
- linux expect 用法小记
- linux expect 用法小记
- Linux expect用法
- linux expect 用法小记
- Linux expect 用法
- Linux expect用法
- linux expect spawn、linux expect 用法
- expect spawn、linux expect 用法小记
- expect spawn、linux expect 用法小记
- js获取html中的table元素里的每一行的行号
- PAT 1009. 说反话
- Android 使用Log4j把日志写入SD卡,动态修改输出文件名称
- 判断是否为闰年
- Guide Practice of Perl
- linux expect的用法
- 向左轮播滑动
- Codeforces Round #295 (Div. 2) A+B+C
- IOS学习初期的一些学渣感受[参考意义在于学习的顺序过程]
- 大数相乘
- C++虚函数
- 使用C++实现一套简单的状态机模型——实例
- 关于struct,enum和typedef的知识总结
- 记忆背包