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

2019-03-09 18:59发布

问题:

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

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

My username is info@domain.com and it thinks my host is domain.com.

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

回答1:

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

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


回答2:

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



回答3:

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

machine host login info@domain.com password mypassword

Check man netrc for details.



回答4:

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

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



回答5:

curl -f -s --disable-epsv -u someone@somewhere.com:gr8p455w0rd -T /some/dir/filename ftp://somewher.com/ByramHealthcareCenters/byram06-2011.csv



回答6:

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

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

Do the unattended upload with curl instead of ftp:

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

%40 doesn't appear to work.

[~]# ftp domain.com
ftp: connect: Connection refused
ftp> quit
[~]# ftp some_user%40domain.com@domain.com
ftp: some_user%40domain.com@domain.com: 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 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): some_user@domain.com
331 User some_user@domain.com OK. Password required
Password:
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.


回答7:

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

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

ftp -u user\@domain.tld@ftp.host.tld


标签: linux ftp