【问题标题】:How to rewrite bash script without lftp?如何在没有 lftp 的情况下重写 bash 脚本?
【发布时间】:2017-12-06 12:47:49
【问题描述】:

这是我的脚本,它使用lftp 命令。我怎样才能重写该脚本,使其功能相同但不使用 lftp?如果使用标准的 linux 工具就好了。

#!/bin/bash
HOST=''
USER=''
PASS=''
TARGETFOLDER='/'
C_DIR=$(readlink -f .)
SOURCEFOLDER=$C_DIR'/exports'

lftp -f "
open $HOST
user $USER $PASS
lcd $SOURCEFOLDER
mirror --reverse --verbose --ignore-time --only-newer $SOURCEFOLDER         $TARGETFOLDER
bye
";
mv exports/*.xml exports/_exports_done/

感谢您的帮助!

【问题讨论】:

标签: bash shell


【解决方案1】:

来自 Michael O. 评论提供的链接。 How to recursively download a folder via FTP on Linux

# command to test
wget -P "$TARGETFOLDER" -r -m --user="$USER" --password="$PASS" "ftp://$HOST/$SOURCEFOLDER"

编辑:由于 lftp --reverse 选项,wget 命令应该在目标服务器上执行

【讨论】:

  • 那么文件应该镜像到哪里?
猜你喜欢
  • 2018-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多