The first thing needed is the ftp script:
#!/bin/bash ftp -in ftp.hostname.com << SCRIPTEND user [email protected] ftppassword binary cd /backups mget filename.tar.bz2 SCRIPTEND ./alertmail
The next one is the email alert that is sent automatically when the task is over:
$cat alertmail #!/bin/bash echo "This is the server at joel.co.in. Your file has been downloaded!" | mail -s "FTP task done" "[email protected]"[
The next is a script that invokes nohup to prevent the task from terminating when the shell terminates:
cat dontcancel #!/bin/bash nohup $1
An ampersand may be inserted at the end to keep the process in the background.