Hi, I have some backup scripts running.
They allocate the files in separated folders, according to the current day.
(01, 02, 03...., 31)
After 1 month, the "cycle" starts again, and the files are uploaded to the folder 01, 02...
When that happens, I want the previous files to be deleted, so that I can put the new ones.
The backup script looks something like this:
I want to use mdelete to delete the older files, so it would look something like
I would appreciate your help.. I've tried every kind of regex...
Thanks in advance...
Last edited by Corona688; 04-10-2012 at 06:00 PM..
Reason: code tags for code, please
Further to Corona688's excellent post.
If you have three separate runs of ftp (directory run; delete run; transfer run) you can first find out which files (if any) are present in the target directory, then delete them in a controlled manner if required, then transfer the new files.
Btw. In the script posted your mput will only transfer one file (if it exists ... which is unlikely).
Hi!
Corona688, methyl
This script transfers only one file each time it runs, the problem is that it runs several times a day.
It would be a perfect solution to delete everything on the folder before uploading, but I don't want to delete everything, I just want to delete files that were created "last" month.
Supposing it is the third time today that the script runs, it would delete the first and second copies I've done today, while I just wanted to delete copies from previous months.
I was thinking about using a wildcard that indicates difference, but I've tried several methods and it didn't work... Looks like only the wildcard "*" is permitted in this case (correct me if I'm wrong).
I've also tried to use RegEx, but it didn't work.
The third "solution" I've been thinking about is to use a similar way this post explains
unix . com/shell-programming-scripting/24085-how-get-previous-month-files.html
(I'm sorry, I can't post url formatted, since I'm a new user)
(Calculating the last month, and deleting last month files with mdelete and * wildcard)
But my knowledge is very limited when it comes to linux, and I couldn't make it work. I think it must have something to do with the
I'm using...
Last edited by rafaces; 04-11-2012 at 09:32 AM..
Reason: Malformatted code
If you want the date in the form YYYY-MM , Try:
Beware. There is a design issue in the script. When there are less days in this month than last month the process will not run for the day numbers which do not exist this month.
You may find it easier to break the process down into separate modules.
1) FTP: Get a directory listing of the remote directory
2) SHELL: Process the directory listing to find files not dated this month
3) FTP: Delete the surplus files (if any are found)
4) FTP: Transfer the new file
Footnote: FTP is not Shell. It knows nothing about regex . Some versions have trouble with complex filenames.
OS: Solaris 9
Configuration /etc/syslog.conf
daemon.debug
/etc/inetd.conf
ftp stream tcp6 nowait root /usr/sbin/in.ftpd in.ftpd -A -l -d
Found the ftp.log only generate those entries from other servers/hosts.
Can we trace on all ftp entries either from/to the server?
... (6 Replies)
Hello All,
I am trying to connect to ftp server and get the files. Also i need to rename the file in other ftp dir.
rename method is not allowing me to rename the file in other dir. When i tried copy command by using net::FTP:FILE then perl says it is not installed.
Can some body help me to... (2 Replies)
how to connect to ftp server in passive mode?
ftp server.abc
and how can i see ftp settings, doesn't exist some ftpd.conf
there is some other file where i check the options and configurations of ftp server?
Thanks (3 Replies)
Hi all,
I'm using the following script to automated ftp files to 1 ftp servers
host=192.168.0.1
/usr/bin/ftp -vi >> $bkplog 2>&1 <<ftp
open $host
bin
cd ${directory}
put $files
quit
ftp
and the .netrc file contain
machine 192.168.0.1
login abc... (4 Replies)
Hi,
I have a ftp script which first gets all the file names and echo's the latest file.
I'm using another ftp command sets to get the file name given by first ftp. The problem is the parameter is not accepted by second ftp. The error message i'm getting is
> Rename Temp File calloc:ICMP... (5 Replies)
Hi,
We have some clients who will place huge files in to one of the remote server.
And the shell script written in our local server to retrieve client files (using FTP) placed on one of the remote server of ours by clients.
My question Is there any FTP command/script to check from my local... (1 Reply)
What I need to do is ftp some files on a remote server, but before postong the file need to delete any existing file from the path on the remote dir.
I am using the mdelete command for the same as follows :
open server_name
user_id
password
prompt off
ascii
cd /test
mdelete *
IF the... (3 Replies)
Hello,
I have a big problem with mdelete and I don't know further. In my shell script mdelete filename1 filename2 filename3 etc. does not delete alle files.
Here's the log:
-rw-r--r-- 1 root root 1 Mar 7 14:40 corrado
-rw-r--r-- 1 root root 1 Mar 7 14:40... (1 Reply)
hi to all!
im using hp-ux 10.2
is it posible for the mdelete command to execute on the root directory if it did not find any file on the specified sub-directory?
this is my sample script
USER=root
PASSWD=root
cd /u01/app/oralog/arch
ftp -n 192.119.10.3
user $USER $PASSWD
prompt... (2 Replies)
We are transferring file from mainframes to unix, & in FTP process itself we would like to set access rights for
unix machine.
Has anyone used chmod command in association with site command in ftp? How it should be used?
Thanks in advance. (1 Reply)