sch远程拷贝自动输入密码expect小脚本
2014-05-04 17:30
393 查看
#!/usr/bin/expect
#Author Aladin
#date 20140504
#auto input passwd
#Version 1.0
spawn scp -P22 /root/shell_test/123.txt root@192.168.0.80:/tmp/
set timeout 100
expect "root@192.168.0.80's password:"
set timeout 10
send "123456\r"
#expect eof
interact
#注意:服务器需要安装expect
一、源码包安装要安装expect,linux expect的安装1.安装相应的包 yum install -y tcl tclx tcl-devel2.下载expect-5.43.tar.gz包(我这里用的这个包,大家也可以用别的)根据参数,运行./configure
./configure --with-tcl=/usr/lib --with-tclinclude=/usr/include/tcl-private/generic
3.make && make install 安装完毕
二、yum 安装 yum install -y expect
问题处理:
./auto_scpfile.sh: line 2: spawn: command not found
couldn't read file "password:": no such file or directory
./auto_scpfile.sh: line 8: send: command not found
./auto_scpfile.sh: line 10: interact: command not found
这样的话,脚本要指定expect: #!/usr/bin/expect
#Author Aladin
#date 20140504
#auto input passwd
#Version 1.0
spawn scp -P22 /root/shell_test/123.txt root@192.168.0.80:/tmp/
set timeout 100
expect "root@192.168.0.80's password:"
set timeout 10
send "123456\r"
#expect eof
interact
#注意:服务器需要安装expect
一、源码包安装要安装expect,linux expect的安装1.安装相应的包 yum install -y tcl tclx tcl-devel2.下载expect-5.43.tar.gz包(我这里用的这个包,大家也可以用别的)根据参数,运行./configure
./configure --with-tcl=/usr/lib --with-tclinclude=/usr/include/tcl-private/generic
3.make && make install 安装完毕
二、yum 安装 yum install -y expect
问题处理:
./auto_scpfile.sh: line 2: spawn: command not found
couldn't read file "password:": no such file or directory
./auto_scpfile.sh: line 8: send: command not found
./auto_scpfile.sh: line 10: interact: command not found
这样的话,脚本要指定expect: #!/usr/bin/expect
相关文章推荐
- linux下scp远程拷贝文件无需输入密码工具之expect
- linux 下采用scp远程传送文件,采用expect技术,支持自动输入密码
- scp批量自动远程复制脚本不需要输入密码
- 自动远程拷贝expect脚本
- 利用scp自动输入密码进行文件远程拷贝或备份
- linux、mac上用expect脚本实现脚本自动输入密码
- 添加自动远程连接的脚本,自动输入密码,节省时间。
- 利用scp自动输入密码进行文件远程拷贝或备份
- 使用expect脚本实现Linux中自动输入密码
- shell脚本通过expect脚本实现自动输入密码
- Shell脚本中调用expect,实现自动输入密码的功能
- 利用scp自动输入密码进行文件远程拷贝或备份
- 利用scp自动输入密码进行文件远程拷贝或备份
- linux、mac上用expect脚本实现脚本自动输入密码
- shell脚本通过expect脚本实现自动输入密码(使用expect)
- 在 Linux 命令行脚本中执行 sudo 等命令时自动输入密码(使用expect)
- 第三步 使用scp远程拷贝,自动输入用户名和密码
- 普通用户利用脚本及runas自动更改IP(无需输入密码)
- 无密钥登录的自动脚本实现(ssh-copy-id、expect免交互输入脚本)
- 使用expect实现ssh自动输入密码,从而自动登陆Linux