无交互shell脚本上传文件至服务器
#!/bin/bash CUR_DIR=`pwd` PKT_DIR="$CUR_DIR" REMOTE_USER=$remote_user REMOTE_HOST=$remote_host REMOTE_PASS=$remote_pass expect <<-END2 spawn sftp $REMOTE_USER@$REMOTE_HOST expect { "Are you sure you want to continue connecting (yes/no)?" { send "yes\r" expect "password:" send "$REMOTE_PASS\r" } "password:" { send "$REMOTE_PASS\r" } } expect ">" { send "cd /opt\r" send "put $PKT_DIR/*\r" send "put ./tar.sh\r" } expect "*" send "exit\r" expect eof END2
本文出自 “果子” 博客,请务必保留此出处http://chenqin.blog.51cto.com/2356777/1381006
无交互shell脚本上传文件至服务器,布布扣,bubuko.com
原文:http://chenqin.blog.51cto.com/2356777/1381006