Create automatic ftp transfer script behind proxy on Windows

Written by - 2 comments

Published on - Listed in Windows Network


To create a batch script, which automatically makes an ftp transmissions is easy to do; but what if the host has no direct ftp access to the Internet and must use a proxy server?

Actually, it is not that different but the ftp syntax changes a lot. Once one knows how to do it is is soo easy.

Let's take a look at the batch file which will be executed on a daily manner (by the Windows Task Scheduler):

transfer.bat:

@echo off
echo "Automatic File Transfer"
echo "-----------------------------------"
ftp -s:ftplist.txt

Well this wasn't really different from a normal ftp batch file, the difference is the ftp syntax in the file which holds the ftp commands (ftplist.txt):

open PROXYSERVER
FTPUSER@FTPHOST PROXYUSER
FTPPASS
PROXYPASS
cd somedir
put test.txt
quit

The big difference is the handling of the connection. Instead of connecting directly to the remote host (FTPHOST), the connection has to be established to the PROXYSERVER (Squid, Bluecoat, etc.).
Then the user authentication seems a bit strange to fellow ftp-users, but that's the way it works: The FTPUSER with the remote FTPHOST (similar to ftp by browser) followed by the user you will authenticate against your PROXYSERVER (your PROXYUSER).
The next two lines indicate the passwords: First the one for the ftp connection, the second one is the password for your proxy user.
After that you can launch your known ftp commands, put, get, dir, etc.



Add a comment

Show form to leave a comment

Comments (newest first)

ck from Switzerland wrote on Jan 25th, 2019:

Hello dl. It's been a long time since I done a batch script. Maybe you should give Filezilla a shot, it also allows to use Filezilla on the command line: https://wiki.filezilla-project.org/Command-line_arguments_(Client). You can prepare the FTP settings in the site manager and then call it from the cli using -c or --site.


dl from wrote on Jan 25th, 2019:

how to do it if I use proxy without credential

thanks


RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Icingaweb   Icingaweb2   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder   


Update cookies preferences