Bash script problem with ftp session exiting the script early
I got this script that backs up a server and then keeps only the last 10 backups and removes the rest. Problem is, the part where it deletes any backups older than the last 10, it never reaches that. I'm guessing it is because the ftp session somehow exits the script entirely, especially if there is a problem with the ftp session. But just to make sure, I'm wondering if you all can look at the code to see if I am making it exit accidentally.
Here's the code. I left out data like ip address and directory/file names for my security purposes. Code:
#ftp in and grab the file |
Apparently the ftp code is correct. The close statement is not necessary, since you don't need to keep the ftp session open for further operations, but that cannot be an issue. You can try to save the stdout and stderr of the ftp command, using the verbose option for checking, e.g.
Code:
ftp -in -v xx.xx.xx.xx << EOF > ftpout.log 2> ftperr.log By the way, are the files you want to retrieve actually downloaded to the local machine? |
ya. the files are there. and when i check if it was transferred, it is. I'm not sure what could be causing this. It could be the get command. I can try using curl and see what happens.
|
I added the ftpout.log and ftperror.log and the error log shows nothing and the out log shows nothing other than navigating through the directories. The files were transferred fine, but the anything after that does not execute. I had an echo line after EOF and it never executed. So I'm still stumped on why it exits.
|
Quote:
Code:
221 Goodbye. |
That worked. I actually had a space after EOF. I also had a #comment after it too. I didn't think that would of affected it when I retyped it on this post so I didn't include it.
Thanks for your help. |
All times are GMT -5. The time now is 04:29 PM. |