Need to FTP files with a bash script

I am making a bash shell script that should look for files in a directory then upload them to an ftp server and move the original file to another directory.

It should ftp then move all files until the folder is empty and then wait 5 minutes before looking for new files.

I understand how to do everything except actually ftp the files to another server.

How do I make this pseudocode into a bash script?
***      ftp movie file to server with id "login" password "password"

while true ; do
for movie in /home/smartdata/www/html/files/encoded/mp4/widescreen16x9/*.* ; do
***	ftp movie file to server with id "login" password "password"
mv /home/smartdata/www/files/encoded/mp4/"$movie" $NEWPATH
echo Waiting 5 minutes
sleep 300 #wait 5 min

Open in new window

Who is Participating?
omarfaridConnect With a Mentor Commented:
here the ftp part:

ftp remoteserver <<-END
cd /dir
put filename

- For ftp to work without providing any username / password,  use .netrc file in the user's home directory (the one who will run the script). This file should not be readable by others i.e. use
chmod 400 .netrc

The entry in .netrc should be as below:

machine remoteserver
login remoteusername
password mypassword

remoteserver is the server which is the ftp server where you want to sent the file(s)
remoteusername is the remote user login name on the ftp server
mypassword is the password of the remote user on the ftp server

for more info about .netrc, please use man netrc
ftp is not secure - especially if you are putting your passwords into files.

if you have an SSH server on the same box you can use the SCP command.  It is as simple as copy command.

for format is similar to :
scp file1.txt servername:/home/user/file1.txt

in the script you could do something like :
scp $filename $remotehost:$path/$filename
Oh - I forgot to say - if you dont want prompts for passwords you'll need to set up ssh keys
All Courses

From novice to tech pro — start learning today.