The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: automated ftp.
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 05-03-2007
sangfroid sangfroid is offline
Registered User
  
 

Join Date: May 2007
Posts: 5
automated ftp.

Hi
I am trying to delete some specific files ( files other than created today) from the server on a cron basis. I wrote a small script, but I am stuck up in how to delete only specific files.


#!/usr/bin/expect -f

set IP [lindex $argv 0]
set timeout -1
spawn ftp $IP
expect ):
send "username\n"
expect word:
send "password\n"
expect ftp>
send "prompt\n"
expect ftp>
send "passive\n"
expect ftp>
send "cd logs/\n"
expect ftp>


After this I am stuck up. It is because I want to delete files with old dates ie, I don't want to delete the file dated today.


The files are like logfile-070501,logfile-070502 and so on..

I cannot run the command "rm logfile-0705*" ( as it will delete today's file too)

By the way, I have the list of files to be deleted in a separate file. I am wondering if by running any other additional script, we can delete selected files from the remote server .

I tried with ! command of ftp, but it runs the commands on local machine.

Your help will be highly appreciated.Thanks