linux scp 自动脚本,scp自动运行脚本
一、
#!/bin/bash
IP=192.168.1.179
PASSWD=123456
content=$(cat <
spawn scp -r root@$IP:/home/CRM /home
send "yes\n"
expect password:
send "$PASSWD\n"
expect eof
)
echo "$content" | expect
二、
1、#yum install expect2、腳本如下
#vi scp.exp
#!/usr/bin/expect -f
spawn scp -r root@192.168.1.179:/home/CRM /home
set timeout 10
expect "root@192.168.1.179's password:"
exec sleep 1
send "123456\n"
interact
3、運行
#expect scp.exp或者
#chmod +x scp.exp
#./scp.exp
三、
#!/bin/bash
IP=192.168.1.179
PASSWD=123456
content=$(cat <
spawn scp -r root@$IP:/home/CRM /home
send "yes\n"
expect password:
send "$PASSWD\n"
expect "Are you sure you want to continue connecting (yes/no)?" { send "yes\r" } "Password:" { send "$PASSWD\r" }
expect eof
)
echo "$content" | expect
總結
以上是生活随笔為你收集整理的linux scp 自动脚本,scp自动运行脚本的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: day32,尚硅谷视频学习中
- 下一篇: Raspberry Pi 4和 Rasp