Linux – Text-based FTP client settings behind the agent

Text-based FTP client settings behind the agent… here is a solution to the problem.

Text-based FTP client settings behind the agent

I need to create a bash script to connect to the FTP server, upload the file, and close the connection. Usually this is a simple task, but I need to specify some specific proxy settings, which makes it difficult.

I can connect to FTP normally using a GUI client (i.e. Filezilla with the following settings:

).

Proxy Settings
--------------
FTP Proxy : USER@HOST
Proxy Host: proxy.domain.com
Proxy User: blank
Proxy Pass: blank

Proxy Settings

FTP Settings
------------
Host : 200.200.200.200
Port : 21
User : foo
Pass : bar

FTP Settings

What I can’t seem to do is replicate these settings in a text-based ftp client (i.e. ftp, lftp, etc.). Can anyone help set up this script?

Thanks in advance!

Solution

According to docs, lftp should support ftp_proxy environment variables, eg

ftp_proxy=ftp://proxy.domain.com lftp -c "cd /upload; put file" ftp://200.200.200.200

If feasible, you can put

export ftp_proxy=ftp://proxy.domain.com

In your shell configuration file, or

set ftp:proxy=ftp://proxy.domain.com

In your ~/.lftprc.

Or, try running a command that your GUI FTP client is running, for example

upload.lftp

USER ...@...
PASS ...
PUT ...

Then run it with -s:

lftp -s upload.lftp 200.200.200.200

Or try curl -T ( docs ) ncftpput ( docs )。

Similar to:

FTP_PROXY=ftp://proxy.domain.com curl -T uploadfile -u foo:bar ftp://200.200.200.200/myfile

May be useful.

Related Problems and Solutions