Shell script to download the file from FTP

#! /bin/sh
REMOTE='127.2.2.2'
USER='usser'
PASSWORD='pass'
FTPLOG='/tmp/log'

date >> $FTPLOG
ftp -in $REMOTE <<_FTP>>$FTPLOG
quote USER $USER
quote PASS $PASSWORD
bin
cd /ftpfolder/source_Extracts # folder path(ftp)
lcd /home/user/souce_files # target folder path(local)
mget *.dat
quit
_FTP

MYSQL To get domain from url

SUBSTRING_INDEX(SUBSTRING_INDEX(TRIM(LEADING 'www.' FROM TRIM(LEADING 'https://' FROM TRIM(LEADING 'http://' FROM TRIM(referring_url)))), '/', 1), ':', 1)

eg: referring_url = www.blogger.com it will return blogger.com

If www. needed the use below query
SUBSTRING_INDEX(SUBSTRING_INDEX(TRIM(LEADING 'https://' FROM TRIM(LEADING 'http://' FROM TRIM(referring_url))), '/', 1), ':', 1)