Problem with sh script file
Hello,
Here is my code: Code:
#!/bin/sh Code:
#!/bin/sh Code:
## Making dmp backup--working fine =================== Its making backup and moving as well as uploading to ftp server but not removing old files When I use it in crontab: ========================= 30 2 * * * sh /var/oracle/dmp-backup-script/dmp.sh>>dmp.log | mail -s "dmp backup tried. check log" xxx@gmail.com Then its only making backup and quit from the script. Please advise |
There is no such thing as "find" in ftp.
Ignore your script for a minute, and just run your ftp commands manually: Code:
ftp -n -v hostname Also, you should not be using names in all caps for local variables. All caps is reserved for environment variables, using it for local variables can cause all kinds of unexpected conflicts. For example, $USER is already an environment variable that contains the username of the user that is running the script. You're overwriting this variable with your ftp user name, which means anything down the line that references $USER for any reason, will receive your ftp user name instead of the local system's user name, which can cause all kinds of problems. |
As stated in your other thread ftp does have the capabilities to delete files and directories. It is not as simple as the find command and what makes it more difficult is if you do not run the script everyday.
http://ss64.com/bash/ftp.html |
I chanaged variables as you advised and now this script look like:
Code:
#!/bin/sh Code:
# sh xx.sh thanks |
you can insert
Code:
set -x just to see what's happening |
Why do you use prompt command in a ftp script?
I'd rather use ' prompt off ' |
Quote:
|
Quote:
Code:
[root@centos backup-scripts]# sh fazool.sh |
Quote:
|
it was stated in post #3.
you may want to try rsync instead of ftp. |
Quote:
|
1. You seem to have a problem with the basic tools and utilities. While there are problems with your script, the major issues are your misunderstanding of ftp and other gnu software rather than the shell.
2. Your script has no error checking at all, so there is significant opportunity for much unexpected behavior resulting from a single error. My advice, after studying your tools and what they can and cannot do, is to consider this only a start. You will want to tune and improve your process for some time as you learn these things. One thought I had at first glance is that some tool that can be scripted might be a better option. ftp can read and use scripts, but these are scripts of ftp commands and you need to understand those limitations mentioned. lftp is more powerful, handles additional protocols, and has more scripting options: it may be worth consideration. No matter what tools you use, before deleting files you will want to test the error return from the transport mechanism to ensure that they are safely transferred elsewhere before you delete the local copy. I would also want to add error detection to any called script, and a return code that would tell the parent script something about the results. If ssh and sftp are options, they provide ways to securely execute a command on the remote host. (your find, perhaps) lftp also supports sftp protocol. If ssh/sftp is an option, those offer more security, greater power, and superior error detection. I often use the putty-tools versions, as they allow options better suited to some kinds of scripting, but the basic tools from OpenSSH work well. Finally, you are running on CentOS. The default shell is normally bash, with sh being a link to bash that runs in a more posix mode. Using bash explicitly opens up a little more power. You MAY want to consider that, if this does not need to be portable to non-bash based distributions. Looks like fun! |
To put it in simple words. You can not use find.
ftp has a very limited number of commands which are defined in the link I provided above. find is a command line utility and only available using telnet or ssh. In your previous thread you stated that ssh was not available by your ISP. |
I found this script http://stackoverflow.com/questions/1...files-from-ftp
Code:
#!/bin/bash Code:
removing files older than Jul 06 |
obviously you modified that script. Again, you can put set -xv at the beginning to see what's happening, I cannot guess...
|
All times are GMT -5. The time now is 05:22 AM. |