【发布时间】:2014-08-23 18:40:03
【问题描述】:
我正在尝试使用 UNIX shell 脚本自动执行我的 SFTP 命令,但由于某种原因它不起作用。这是我的代码如下。请分享您的想法/见解。
#This ftp script will copy all the files from source directory into the local directory.
#!/bin/sh
HOST='sftp.xyz.com'
USER='ABC'
PASSWORD='123'
SRC_DIR='From_Src'
TRGT_DIR='/work/'
FILE='abc.txt'
sftp -u ${USER},${PASSWORD} sftp://${HOST} <<EOF
cd $SRC_DIR
lcd $TRGT_DIR
get $FILE
bye
EOF
echo "DONE"
当我尝试执行上述代码时,出现以下错误。
sftp: illegal option -- u
usage: sftp [-1246Cpqrv] [-B buffer_size] [-b batchfile] [-c cipher]
[-D sftp_server_path] [-F ssh_config] [-i identity_file] [-l limit]
[-o ssh_option] [-P port] [-R num_requests] [-S program]
[-s subsystem | sftp_server] host
sftp [user@]host[:file ...]
sftp [user@]host[:dir[/]]
sftp -b batchfile [user@]host
【问题讨论】:
-
请定义“不起作用”。预期的行为是什么?会发生什么?
-
添加了我收到的异常。
-
您必须拥有
expect还是会考虑其他选项? -
我很擅长其他选项以及anubhav ...
-
嗨 Anubhav... 祝你好运... 我仍然被这个问题困扰.. :(