3

我目前处于对服务器的访问权限非常有限的情况,但需要上传和下载包含在单个目录结构中的大量文件。我没有 SSH 访问权限,所以我不能使用 SCP - 不幸的是,rsync 也不是一个选项。

我目前正在使用 ncftpput,它很棒,但似乎很慢(尽管连接速度很快)。

有没有我可以研究的替代/更好的方法?

(如果这已经涵盖,请接受我的道歉,我在发布之前进行了快速搜索,但没有找到任何具体回答我的问题的内容)

4

5 回答 5

4

尝试使用 LFTP: http ://lftp.yar.ru/

或 YAFC:http: //yafc.sourceforge.net/index.php

于 2009-09-10T02:41:27.797 回答
2

如果您有良好的连接,我建议您通过 GNOME 或 KDE 文件管理器安装 ftp 服务器,或者使用CurlFtpFS。然后你可以把它当作另一个文件夹。

于 2009-09-10T03:44:46.117 回答
1

我不熟悉ncftpput。对于非交互式 FTP,我一直使用 Perl Net::FTP 模块 -- http://perldoc.perl.org/Net/FTP.html

这会更快,因为您可以登录,然后一次进行所有传输(粗略一看,您似乎ncftpput对每个文件 get/put 执行一次)。

只要记住永远不要使用 ASCII 修改!这是默认设置,因此请使用:

$ftp->binary

ASCII 修改需要与 MySQL 自动时区解释在同一场大火中死去。

于 2009-09-10T02:27:03.597 回答
0

由于我总是遇到这个问题,所以我会在这里发布我的笔记:

我总是混淆的一件事是语法。所以下面有一个bash测试脚本,它创建一些临时目录,然后启动一个临时 ftp 服务器,并比较rsync(在纯本地文件模式下,因为它不支持 ftp)与lftpand ftpsync

问题是 - 你可以使用rsync /path/to/local /path/to/remote/,并且 rsync 会自动找出你想要在;local下创建一个子目录。remote但是,对于lftp或者ftpsync必须手动指定目标目录,如... /path/to/local /path/to/remote/local(如果它不存在,它将被创建)。

您可以ftpserver-cli.py如何临时运行 FTP 服务器?- 询问 Ubuntu;并且ftpsync在这里:FTPsync(但是,请注意它是错误的;另请参阅Search/grep ftp remote filenames - Unix & Linux Stack Exchange);

这是puttest.sh脚本的简短输出,显示了不同情况下的递归 put 行为:

$ bash puttest.sh 
Recreate directories; populate loctest, keep srvtest empty:
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
/tmp/loctest
├── .git
│   └── tempa2.txt
└── tempa1.txt

*NOTE, rsync can automatically figure out parent dir:
+ rsync -a --exclude '*.git*' /tmp/loctest /tmp/srvtest/
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
└── loctest
    └── tempa1.txt
/tmp/loctest
├── .git
│   └── tempa2.txt
└── tempa1.txt
cleanup:
+ rm -rf /tmp/srvtest/loctest

Start a temporary ftp server:
+ sudo bash -c 'python /path/to/pyftpdlib/ftpserver-cli.py --username=user --password=12345 --directory=/tmp/srvtest &'
+ sleep 1
Using: user: user pass: 12345 port: 21 dir: /tmp/srvtest
[I 14-03-02 23:24:01] >>> starting FTP server on 127.0.0.1:21, pid=21549 <<<
[I 14-03-02 23:24:01] poller: <class 'pyftpdlib.ioloop.Epoll'>
[I 14-03-02 23:24:01] masquerade (NAT) address: None
[I 14-03-02 23:24:01] passive ports: None
[I 14-03-02 23:24:01] use sendfile(2): False
test with lftp:

*NOTE, lftp syncs *contents* of local dir (rsync-like syntax doesn't create target dir):
+ lftp -e 'mirror -R -x ".*\.git.*" /tmp/loctest / ; exit' -u user,12345 127.0.0.1
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
└── tempa1.txt
/tmp/loctest
├── .git
│   └── tempa2.txt
└── tempa1.txt
cleanup:
+ rm -rf /tmp/srvtest/tempa1.txt

*NOTE, specify lftp target dir explicitly (will be autocreated):
+ lftp -e 'mirror -R -x ".*\.git.*" /tmp/loctest /loctest ; exit' -u user,12345 127.0.0.1
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
└── loctest
    └── tempa1.txt
/tmp/loctest
├── .git
│   └── tempa2.txt
└── tempa1.txt
cleanup:
+ sudo rm -rf /tmp/srvtest/loctest

*NOTE, ftpsync syncs *contents* of local dir (rsync-like syntax doesn't create target dir); also info mode -i is buggy (it puts, although it shouldn't):

*NOTE, ftpsync --ignoremask is for older unused code; use --exclude instead (but it is buggy; need to change  in source)
+ /path/to/ftpsync/ftpsync -i -d '--exclude=.*\.git.*' /tmp/loctest ftp://user:12345@127.0.0.1/
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
└── tempa1.txt
/tmp/loctest
├── .git
│   └── tempa2.txt
└── tempa1.txt
cleanup:
+ sudo rm -rf /tmp/srvtest/tempa1.txt

*NOTE, specify ftpsync target dir explicitly (will be autocreated):
+ /path/to/ftpsync/ftpsync -i -d '--exclude=.*\.git.*' /tmp/loctest ftp://user:12345@127.0.0.1/loctest
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
└── loctest
    └── tempa1.txt
/tmp/loctest
├── .git
│   └── tempa2.txt
└── tempa1.txt
cleanup:
+ sudo rm -rf /tmp/srvtest/loctest
+ sudo pkill -f ftpserver-cli.py

而且,这是puttest.sh脚本:

#!/usr/bin/env bash
set -x

# change these to match your installations:
FTPSRVCLIPATH="/path/to/pyftpdlib"
FTPSYNCPATH="/path/to/ftpsync"

{ echo "Recreate directories; populate loctest, keep srvtest empty:"; } 2>/dev/null

sudo rm -rf /tmp/srvtest /tmp/loctest

mkdir /tmp/srvtest

mkdir -p /tmp/loctest/.git
echo aaa > /tmp/loctest/tempa1.txt
echo aaa > /tmp/loctest/.git/tempa2.txt

{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest

{ echo -e "\n*NOTE, rsync can automatically figure out parent dir:"; } 2>/dev/null

rsync -a --exclude '*.git*' /tmp/loctest /tmp/srvtest/

{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest

{ echo "cleanup:"; } 2>/dev/null
rm -rf /tmp/srvtest/*

{ echo -e "\nStart a temporary ftp server:"; } 2>/dev/null

# https://askubuntu.com/questions/17084/how-do-i-temporarily-run-an-ftp-server

sudo bash -c "python $FTPSRVCLIPATH/ftpserver-cli.py --username=user --password=12345 --directory=/tmp/srvtest &"
sleep 1

{ echo "test with lftp:"; } 2>/dev/null
# see http://russbrooks.com/2010/11/19/lftp-cheetsheet
# The -R switch means "reverse mirror" which means "put" [upload].
{ echo -e "\n*NOTE, lftp syncs *contents* of local dir (rsync-like syntax doesn't create target dir):"; } 2>/dev/null

lftp -e 'mirror -R -x ".*\.git.*" /tmp/loctest / ; exit' -u user,12345 127.0.0.1

{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest

{ echo "cleanup:"; } 2>/dev/null
rm -rf /tmp/srvtest/*

{ echo -e "\n*NOTE, specify lftp target dir explicitly (will be autocreated):"; } 2>/dev/null

lftp -e 'mirror -R -x ".*\.git.*" /tmp/loctest /loctest ; exit' -u user,12345 127.0.0.1

{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest

{ echo "cleanup:"; } 2>/dev/null
sudo rm -rf /tmp/srvtest/*

{ echo -e "\n*NOTE, ftpsync syncs *contents* of local dir (rsync-like syntax doesn't create target dir); also info mode -i is buggy (it puts, although it shouldn't):"; } 2>/dev/null
{ echo -e "\n*NOTE, ftpsync --ignoremask is for older unused code; use --exclude instead (but it is buggy; need to change `  'exclude=s' => \$opt::exclude,` in source)"; } 2>/dev/null

$FTPSYNCPATH/ftpsync -i -d --exclude='.*\.git.*' /tmp/loctest ftp://user:12345@127.0.0.1/

{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest

{ echo "cleanup:"; } 2>/dev/null
sudo rm -rf /tmp/srvtest/*

{ echo -e "\n*NOTE, specify ftpsync target dir explicitly (will be autocreated):"; } 2>/dev/null

$FTPSYNCPATH/ftpsync -i -d --exclude='.*\.git.*' /tmp/loctest ftp://user:12345@127.0.0.1/loctest

{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest

{ echo "cleanup:"; } 2>/dev/null
sudo rm -rf /tmp/srvtest/*


sudo pkill -f ftpserver-cli.py

{ set +x; } 2>/dev/null
于 2014-03-02T22:45:05.320 回答
0

没有提到ncftp

在 Ubuntu 中,sudo apt install ncftp

于 2019-12-09T16:16:17.103 回答