我的Cron:
* 1 * * * ./public/xfer.sh > ./public/xferlog.log
我的剧本:
HOST='255.255.255.255'
USER='myadminuser'
PASSWD='supersecretpassword'
ftp -n -v -i $HOST<<EOF
quote USER $USER $PASSWD
lcd /usr/www/xxxx/public/svss/cq
ascii
cd svss
get pbsvss.htm
binary
close
EOF
给我这些错误..
./xfer.sh: line 4: $'\r': command not found
./xfer.sh: line 14: warning: here-document at line 5 delimited by end-of-file (w')ted `END_SCRIPT
(255.255.255.255)..255.255.255
220 Microsoft FTP Service
Remote system type is Windows_NT.
331 Password required for myadminuser .
530 User cannot log in.
usage: lcd local-directory
200 Type set to A.
530 Please login with USER and PASS.
remote: pbsvss.htm
530 Please login with USER and PASS.
ftp: bind: Address already in use
200 Type set to I.
221 Goodbye.
?Invalid command
答案 0 :(得分:0)
没关系,我决定用wget做这件事。
现在我所要做的就是以下1行代码,
wget -P /path/to/save/to/ -nH --cut-dirs=1 -m ftp://user:pass@ip.or.hostname/directory/
答案 1 :(得分:0)
我如何解决安全问题绝不会将原始密码传递给脚本。
像这样的东西(显然我采取了进一步的步骤,但这是它的基础) 我在shell中,
echo -n 'mysecretpass' | base64
c2NvdHRsaW51eC5jb20gcm9ja3MK
然后在脚本中我只使用cmdline中的输出
$pass = c2NvdHRsaW51eC5jb20gcm9ja3MK | base64 --decode