Mac OSX 10.13.3 系统下亲测没问题,直接看代码:
#!/bin/bash lfname=tencentcloud_poc_ljl_0009 #这里是任何bash 命令 ls printf "\n"; printf "starting scp $lfname-1.0-2.app.zip....\n"; printf "\n"; #这里开始利用 expect 执行scp 并实现自动输入密码 /usr/bin/expect<<EOF set timeout -1 spawn scp ./apspackages/$lfname-1.0-2.app.zip [email protected]10.X.X.X:/root/ljlapp expect { "*assword" {send "password\r";} "yes/no" {send "yes\r"; exp_continue;} } expect eof EOF printf "done..\n"
原文地址:https://www.cnblogs.com/jlli/p/8874708.html
时间: 2024-11-06 07:59:02