以脚本格式(在Mac OSX High Sierra上为bash shell)使用sftp相对较新。登录远程服务器后,我在更改目录时遇到问题。我想CD到“ FTP PDF(下载)到CR” 这是我的脚本(已编辑):
#!/bin/bash
expect -c "
spawn sftp ClaimReturn@8.19.132.155
expect \"Password\"
send \"xxxxxxx\r\"
expect \"sftp>\"
send \"cd CR\ Reports\r\"
#DIR TO CD to "CR REPORTS"
expect \"sftp>\"
send \"bye\r\"
expect \"#\"
"
答案 0 :(得分:0)
这实际上只是格式化的注释,扩展了@meuh的注释。
您在报价时遇到麻烦。您可以使用单引号或带引号的Heredoc来简化生活
#!/bin/bash
expect <<'END_EXPECT'
spawn sftp ClaimReturn@8.19.132.155
expect "Password"
send "xxxxxxx\r"
expect "sftp>"
send "cd 'CR Reports'\r"
#DIR TO CD to "CR REPORTS"
expect "sftp>"
send "bye\r"
expect "#"
END_EXPECT
或者,只是一个期望脚本:
#!/usr/bin/expect -f
spawn sftp ClaimReturn@8.19.132.155
expect "Password"
send "xxxxxxx\r"
expect "sftp>"
send "cd 'CR Reports'\r"
#DIR TO CD to "CR REPORTS"
expect "sftp>"
send "bye\r"
expect "#"