LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   AIX (https://www.linuxquestions.org/questions/aix-43/)
-   -   Setting up a cron for transferring a file through FTP at 5 PM daily (https://www.linuxquestions.org/questions/aix-43/setting-up-a-cron-for-transferring-a-file-through-ftp-at-5-pm-daily-934622/)

druuna 03-16-2012 11:44 AM

Hi,

Which OS are you using? Linux (if so: which distro), hp-ux, solaris, sunos, aix, ..?

lithos 03-16-2012 11:49 AM

Have you tried your last line
Code:

find /home/evaxd4/FTP_CRON/ -name "pso_whse_orders_inout.*" -mtime +3 -exec rm -f {} \;
running manually from command line ?

What does it do ?

It may be you don't have $PATH to the Find command, so try use
Code:

/usr/bin/find .....

evilputty 03-16-2012 11:51 AM

you'll need to parse filenames to go by date which is noted within the filename thats why the previous command will not work.

arjundey 03-16-2012 11:54 AM

@druuna - It's a Solaris OS.

@lithos - When I type this command and hit enter, no error is thrown. It just feels like the command has been executed successfully but without effecting the idea behind it - the files to be purged still stays.

@evilputty - I'm new to Unix. Can you please elaborate on how this parsing could be done ?

druuna 03-16-2012 12:10 PM

Hi,
Quote:

Originally Posted by arjundey (Post 4628508)
@druuna - It's a Solaris OS.

That is important information. Solaris is linux alike, but definitely not the same.

I've asked a moderator to move this to the Solaris sub-forum, which will improve the chances for getting the correct answer(s).

evilputty 03-16-2012 01:14 PM

A little googlefu came up with this link.

http://www.linuxquestions.org/questi...please-276744/

Once the cron catches up you should be able to start using
Code:

find /home/evaxd4/FTP_CRON/ -name "pso_whse_orders_inout.*" -mtime +3 -exec rm -f {} \;
since its based off modified time not the time located within the filename.

you could use this script to set the modified time to the existing files to the date appended to the filename.
Code:

#!/bin/sh

for  filename in /location/to/pso_whse_orders_inout.*
do
    MODDATE=`echo $filename | sed -n 's/^.*\.\([0-9]*\)$/\1/p'`
    touch $filename -t $MODDATE"1200"
done;

not sure for solaris but it works fine with linux

colucix 03-16-2012 03:13 PM

Moved: This thread is more suitable in Solaris/Opensolaris and has been moved accordingly to help your thread/question get the exposure it deserves. Thanks druuna for reporting.

arjundey 03-19-2012 01:36 AM

I am sorry friends. I am actually using AIX Version 6.1 , not Solaris. Apologies !!!!

@colucix - Please move it again to the relevant forum.

@All - I am still not able to figure out the purging of files greater than 3 days old. Any ideas please?

arjundey 03-19-2012 05:28 AM

Ok guys. I just figured out that the same command is working now as the problem was with the time of the file when it was created and not just in the date mentioned in the filename. The command

I am marking this thread as resolved now.

Sorry for the confusion on OS & thanks to everyone who contributed your valuable suggestions.

jlliagre 03-24-2012 04:08 PM

As requested, moved to the AIX forum

ashi.srma1986 11-17-2015 11:42 AM

Quote:

Originally Posted by arjundey (Post 4628221)
Thanks Druuna. FTP connectivity works now, but have 2 more issues to resolve with my script.

I have written this script for a FTP transfer, but I am not able to get the files in the required directory even after the cd command before connecting to FTP. I'm running this script from a different directory & I want the file to come into a specific directory. I assumed to change the working directory before connecting to FTP, but its not working. The file is coming to the same directory where I am running the script from. Please help ASAP.

Also, the script doesn't purge the files which are more than 3 days old. Pls help on this as well.

Note : Both are highlighted in BOLD below.

Code:

#!/bin/ksh

sdir="/var/mqm/tmp/pso/"
filename="pso_whse_orders_inout"
hostname="n0aif01"
username="evaxd4"
password="march2012"

`cd $sdir`
ftp -in $hostname <<EOF
quote USER $username
quote PASS $password

binary
cd $sdir
get $filename
quit
EOF

mv -f $filename $filename.`date '+%Y%m%d'`

find /home/evaxd4/FTP_CRON/ -name "pso_whse_orders_inout.*" -mtime +3 -exec rm -f {} \;

In the last command. I want to purge older than 3 days files.

Like for example, there are the following files in the directory :
pso_whse_orders_inout.20120312
pso_whse_orders_inout.20120313
pso_whse_orders_inout.20120314
pso_whse_orders_inout.20120315
pso_whse_orders_inout.20120316

Then the directory will be left over with the last 3 days' files :
pso_whse_orders_inout.20120314
pso_whse_orders_inout.20120315
pso_whse_orders_inout.20120316

Any ideas ?


how i can download all files from specific folder from remote computer

NevemTeve 11-18-2015 03:41 AM

> how i can download all files from specific folder from remote computer

Use wget(1)

Code:

wget -r ftp://user:pass@host//dir/


All times are GMT -5. The time now is 12:00 AM.