使用Expect的SFTP [英] SFTP using Expect

查看:179
本文介绍了使用Expect的SFTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已尝试使用bash脚本将以下脚本用于SFTP.但这是行不通的.总是在输入密码时出错.

I have tried the script below to SFTP using bash script. But it does not work. Always error at password.

/usr/local/bin/expect <<EOF
spawn sftp PG1@dev1.dummy.com
expect "Password:"
send "abc123\r"
expect "sftp>"
send "cd /tmp\r"
send "get Data.dat\r"
send "get List.dat\r"
send "bye\r"
EOF

在接受响应者的所有建议之后,这是我运行上述脚本时的日志文件.

Here's the log file when I run the script above, after taking in all the suggestions from responders.

######### StartJob #########
Sun Apr 19 09:59:08 MYT 2015
spawn sftp PG1@dev1.dummy.com^M
Connecting to dev1.dummy.com...^M
Password: ^M
sftp> ERROR: Data file Data.dat not successfully extracted!
Sun Apr 19 09:59:12 MYT 2015
########## EndJob #########

推荐答案

感谢您为解决上述问题所做的尝试.我找到了解决方案.这是我所做的:

Thank you for your attempts to solve the problem above. I found the solution. Here's what I did:

/usr/local/bin/expect <<EOF
spawn sftp PG1@dev1.dummy.com
expect "Password:"
send "abc123\r"
expect "sftp>"
send "cd /tmp\r"
expect "sftp>"
send "get Data.dat\r"
expect "sftp>"
send "get List.dat\r"
expect "sftp>"
send "bye\r"
EOF

这篇关于使用Expect的SFTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆