In over my head - scripting in bash for FTP
Posted on 2006-10-31
I'm throwing all the points I have into this question.
I am writing a script that will automate an FTP process that is currently a manual process at the moment.
A directory sits out on the file system. An administrator goes in, creates the directory structure on the remote server to match the local directory structure, then copies all the files locally to the remote server via ftp.
I have written a script that can automatically login and create a directory structure based upon a predefined set of rules.
This same script can copy an entire directory over to the remote server so long as the directory structure already exists.
However, I do not know how to implement into the script the results of a find command that gives me all the files that have been modified in the last 24 hours (find -ctime -1). I have a script that runs the find command and dumps the data into a file called changed.txt. I also do not know how to dynamically create the directory structure on the remote machine. When I try to do a copy without creating it, I get an error that the file cannot be created.
Now, all paths are relative to a predefined path (/mnt/raid/JPG). Within this JPG directory it's broken down further (07/PB/01_Hardware/Filename_to_copy.jpg - as an example). On the remote directory, relative from login root (/) I need it to create a directory 07, a directory 07/PB, a directory 07/PB/01_hardware, then copy the file over. And I need to do this from a list that is in my changed.txt file.
I know I can feed data into a script by using <<. However, I don't know what that looks like to the script. I don't even know how to test what that looks like to the script.