How to Download a File via FTP in Delphi XE

A quick example to download a fila via FTP using Indy (IdFTP): uses … IdFTP, IdFTPCommon …   procedure TForm1.Button1Click(Sender: TObject); begin IdFTP1.Host := ‘’; IdFTP1.Port := 21; IdFTP1.ConnectTimeout := 5000; IdFTP1.Username := ‘demo’; IdFTP1.Password := ‘password’; IdFTP1.TransferType := IdFTPCommon.TIdFTPTransferType.ftBinary; IdFTP1.Passive := True;   try IdFTP1.Connect; try IdFTP1.Get(‘/pub/example/pop3-browser.png’, ExtractFilePath(ParamStr(0)) + ‘pop3-browser.png’, True, False); finally IdFTP1.Disconnect; […]

Public FTP Server to Test Upload and Download

For anonymous FTP server you can use this: For username:password FTP server you can use this:

How to Parse Command-Line Arguments in Bash

Need to parse command-line arguments in a bash script? Personally I always use this method: #!/bin/bash   while [[ "$#" -gt 0 ]]; do case $1 in -d|–deploy) deploy="$2"; shift ;; -u|–uglify) uglify=1 ;; *) echo "Unknown parameter passed: $1"; exit 1 ;; esac shift done   echo "Should deploy? $deploy" echo "Should uglify? $uglify"#!/bin/bash […]

How to Make Iptables Rules Persistent

There is Debian package named “iptables-persistent”. iptables-persistent makes sure iptables rules survive a reboot. To install it just type this command: apt-get -y install iptables-persistentapt-get -y install iptables-persistent To install it in an automated way check this: Bash Install Iptables-Persistent Automatically Other useful info can be found here:

Bash Install Iptables-Persistent Automatically

Check if iptables-persistent is installed, else install it: if [[ $(dpkg -s iptables-persistent) != *"Status: install ok installed"* ]]; then echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections apt-get -y install iptables-persistent fiif [[ $(dpkg -s iptables-persistent) != *"Status: install ok installed"* ]]; then echo iptables-persistent iptables-persistent/autosave_v4 […]

Route OpenVPN Connections Through Floating IP

Assuming you have a Hetzner VPS with a floating IP address: How to Configure a Floating IP in a VPS (Hetzner) Let’s say the floating IP address is as example. And that you have installed OpenVPN via this guide: How to Install OpenVPN in Debian 10 Buster 1) Edit /etc/openvpn/server.conf and add: local […]

How to Configure a Floating IP in a VPS (Hetzner)

First create a Hetzner VPS and attach a floating IP to it. I followed this guide to make sure the floating IP is persistent: How to Make Floating IP Persistent (Hetzner) In short, the procedure is like this: 1) Create a file named 60-my-floating-ip.cfg: vi /etc/network/interfaces.d/60-my-floating-ip.cfgvi /etc/network/interfaces.d/60-my-floating-ip.cfg 2) Paste the following configuration for IPv4: auto […]

Set OpenVPN to Listed on a Specific IP Address

Assuming that default ethernet network interface is eth0. And that you added a new IP on the VPS that got assigned to eth0:1 interface. You can add “local” in your OpenVPN server config, e.g: local So OpenVPN will listen on the specificed IP address. Then you need to restart OpenVPN: /etc/init.d/openvpn […]

Bash Trim Leading and Trailing Whitespace from a String

You can use awk to trim a string, example: echo " test " | awk ‘{$1=$1};1’echo " test " | awk ‘{$1=$1};1’ Another way is to use sed like this: echo " test " | sed -e ‘s/^[[:space:]]*//’ -e ‘s/[[:space:]]*$//’echo " test " | sed -e ‘s/^[[:space:]]*//’ -e ‘s/[[:space:]]*$//’ And also xargs can be used: […]

Bash Get Name of Ethernet Network Interface

Here is a bash command to get name of ethernet network interface: ip link | awk -F: ‘$0 !~ "lo|tun|vir|wg|wl|^[^0-9]"{print $2;getline}’ | awk ‘{$1=$1};1’ip link | awk -F: ‘$0 !~ "lo|tun|vir|wg|wl|^[^0-9]"{print $2;getline}’ | awk ‘{$1=$1};1’ It will exclude lo (local), tun0 (openvpn), wg0 (wireguard), wl* (wireless), etc. If you have multiple ethernet network interface and […]