How could I modify the script below to include the source directory so that it will know which location to retrieve the files required for transfer?
I have a bash script for the purpose of automatically transferring files to a remote server, which occurs once a week.
Here is the script:
#!/bin/bash
HOST=sftp.mydomain.com
USER=user
PASS=pass
ftp -inv $HOST << EOF
$USER $PASS
cd /d D:\destination\directory
put file1.gz
put file2.gz
put file3.gz
bye
EOF
Files 1-3 are all in source/directory, so I'd like to transfer all files from source/directory to the destination path specified above.
However, I believed that because the script is running on the source VM, that I wouldn't need to specify a directory since the script could simply pull it from any folder (rookie mistake, I understand).
Alternatively: is there an easier way to use ftp for an entire directory as opposed to simply listing the entire content of the folder?
sftp
might it be that you could use anssh
-based protocol instead of the ancient and insecureftp
? If this is the case you can look at commands usingsftp
such assftp
andlftp
, and even considerscp
with certificates, which are very much easier to manage than unsecured passwords.cd
command only takes a single argument, no? To transfer the complete contents of a directory hierarchy using FTP, transfer it as atar
archive.lcd
inside the ftp script, or a plain oldcd
before theftp
?