如何在我的用户名中使用带有@ 符号的 linux 命令行 ftp?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/814322/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 17:16:31  来源:igfitidea点击:

How to use linux command line ftp with a @ sign in my username?

linuxftp

提问by bentford

How can I run this on linux command line when my username has an @sign in the middle?

当我的用户名@中间有一个符号时,如何在 linux 命令行上运行它?

ftp -u user:password@host/destination_folder/ sourcefile.txt

My username is [email protected]and it thinks my host is domain.com.

我的用户名是[email protected],它认为我的主机是domain.com

NOTE: This is an unattended upload, so I can't just type in the username and password.

注意:这是一个无人值守的上传,所以我不能只输入用户名和密码。

采纳答案by pts

As an alternative, if you don't want to create config files, do the unattended upload with curlinstead of ftp:

作为替代方案,如果您不想创建配置文件,请使用curl而不是执行无人值守上传ftp

curl -u user:password -T file ftp://server/dir/file

回答by moinudin

Try to define the account in a ~/.netrcfile like this:

尝试在这样的~/.netrc文件中定义帐户:

machine host login [email protected] password mypassword

Check man netrcfor details.

检查man netrc详细信息。

回答by Angus S-F

Try this: use "%40" in place of the "@"

试试这个:使用“%40”代替“@”

回答by Sal

I've never seen the -uparameter. But if you want to use an "@", how about stating it as "\@"?

我从来没有见过-u参数。但是如果你想使用“@”,把它写成“\@”怎么样?

That way it should be interpreted as you intend. You know something like

这样就应该按照你的意图来解释。你知道类似

ftp -u user\@[email protected]

回答by Dennis Comeaux

curl -f -s --disable-epsv -u [email protected]:gr8p455w0rd -T /some/dir/filename ftp://somewher.com/ByramHealthcareCenters/byram06-2011.csv

curl -f -s --disable-epsv -u [email protected]:gr8p455w0rd -T /some/dir/filename ftp://somewher.com/ByramHealthcareCenters/byram06-2011.csv

回答by innovati

I simply type ftp hostdomain.comand the very next prompt asked me to enter a name, if it wasn't the same as my current user.

我简单地输入ftp hostdomain.com,下一个提示要求我输入一个名称,如果它与我当前的用户不同。

I guess it depends on how your FTP is configured. That is, whether it assumes the same username (if not provided) or asks. the good news is that even without a solution, next time you face this it might Just Work? for you :D

我想这取决于您的 FTP 是如何配置的。也就是说,它是否假定相同的用户名(如果未提供)或询问。好消息是,即使没有解决方案,下次您遇到这种情况时,它可能会正常工作吗?给你:D

回答by Stephen

A more complete answer would be it is not possible with ftp(at least the ftp program installed on centos 6).

更完整的答案是 ftp 是不可能的(至少安装在 centos 6 上的 ftp 程序)。

Since you wanted an un-attended process, "pts"'s answer will work fine.

由于您想要一个无人值守的过程,“pts”的答案会很好用。

Do the unattended upload with curl instead of ftp:

使用 curl 而不是 ftp 进行无人值守上传:

curl -u user:password -T file ftp://server/dir/file

%40 doesn't appear to work.

%40 似乎不起作用。

[~]# ftp domain.com
ftp: connect: Connection refused
ftp> quit
[~]# ftp some_user%[email protected]
ftp: some_user%[email protected]: Name or service not known
ftp> quit

All I've got is to open the ftp program and use the domain and enter the user when asked. Usually, a password is required anyway, so the interactive nature probably isn't problematic.

我所拥有的只是打开 ftp 程序并使用域并在询问时输入用户。通常,无论如何都需要密码,因此交互性可能没有问题。

[~]# ftp domain.com
Connected to domain.com (173.254.13.235).
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 2 of 1000 allowed.
220-Local time is now 02:47. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (domain.com:user): [email protected]
331 User [email protected] OK. Password required
Password:
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.