toben88
asked on
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 domain.com with id "login" password "password"
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 domain.com with id "login" password "password"
#!/bin/bash
while true ; do
for movie in /home/smartdata/www/html/files/encoded/mp4/widescreen16x9/*.* ; do
*** ftp movie file to server domain.com with id "login" password "password"
NEWPATH=/home/smartdata/www/html/files/encoded/mp4/uploaded/"$movie"
mv /home/smartdata/www/files/encoded/mp4/"$movie" $NEWPATH
done
echo Waiting 5 minutes
sleep 300 #wait 5 min
done
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh - I forgot to say - if you dont want prompts for passwords you'll need to set up ssh keys
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/file
in the script you could do something like :
scp $filename $remotehost:$path/$filenam