linux借助expect完成自动登录
来源:互联网 发布:java 解压加密zip文件 编辑:程序博客网 时间:2024/06/18 08:48
From: http://www.cnblogs.com/sunss/archive/2010/12/23/1914763.html
在工作中,我需要把远程服务器上的文件,拷贝到本地,可是scp的时候必须输入密码,用here文档又不能实现,终于找到一个好东东,expect ,可以实现自动登录,我们可以借助expect在ssh,ftp,scp等地方实现自动登录,加入到脚本中,可以自动完成一些事情,先把我的测试通过的脚本贴出来:
#!/bin/bash
for i in a b c
do
/usr/bin/expect<<EOF
set timeout 1200;
spawn /usr/bin/scp root@192.168.0.26:/home/sunss/backup/$i/* /root/sss/$i/
expect "root@192.168.0.26's password:"
send "123456\r"
expect eof
EOF
done
ssh远程登录做些操作:
#!/bin/bash
#远程登录重启mysql
/usr/bin/expect<<EOF
set timeout 120;
spawn /usr/bin/ssh root@192.168.0.26
expect "*password:"
send "123456\r"
sleep 1
send "/etc/init.d/mysqld restart\r"
sleep 2
send "exit\r"
expect eof
EOF
- linux借助expect完成自动登录
- Linux expect自动登录ssh
- linux expect, spawn 用expect实现自动登录的脚本
- linux expect自动登录ssh,ftp
- linux expect自动登录ssh,ftp
- linux expect实现自动登录脚本
- linux expect自动登录ssh,ftp...
- linux expect自动登录ssh,ftp
- linux expect自动登录ssh,ftp
- linux expect自动登录ssh,ftp
- linux expect自动登录ssh,ftp
- linux expect详解(ssh自动登录)
- linux expect 自动登录交换机保存配置
- linux expect详解(ssh自动登录)
- linux expect自动登录ssh,ftp
- linux expect自动登录ssh,ftp
- linux expect自动登录ssh,ftp
- linux expect详解(ssh自动登录)
- C# 数据库连接
- 数据加密方法
- 如何在Android下运行C程序
- WM2003se系统软件精选
- Android消息队列(三)--多线程与消息处理
- linux借助expect完成自动登录
- 传说中的c/c++经典网站
- 一花一世界
- mac os x lion 10.7 install xcode 3 (mac os c lion 10.7安装xcode 3)
- 十九、加密技术
- This project needs to migrate WTP metadata
- 二十、脚本参数使用相对路径
- Windows下IPv6地址的形成和使用
- pl/sql 小结