Problem in Weekly file Transfer script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in Weekly file Transfer script
# 1  
Old 05-05-2011
Problem in Weekly file Transfer script

I have made a script which transfers some files of the entire week , but the script fails when the next month is started.
For e.g; if i run the script on 5th may , but i need to transfer files of its previous week which is from 24th April to 30th april ,the script fails, i have this loop in the script
Code:
dt_2=`TZ=CST+$dt date +%Y-%m-%d`

I just put values in $dt which gives me the date to which i need to transfer the files.
For e.g; Considering current date as 2011-05-05, i need to go to date 30th april onwards to 24th april then
24 * 5 = 120
Code:
`TZ=CST+120 date +%Y-%m-%d`

will give me date 2011-04-30.

But the problem here is i am not getting the correct count value,
since i have used cnt1=`expr $1 - $2` which is subtracting two date values , but this does not work for the e.g; which i mentioned above
Could you suggest me a solution on this.
Would appreciate your assistance.
# 2  
Old 05-05-2011
Use my datecalc script. It makes date calculations easy.

Code:
$ cat last-week
#! /bin/ksh

alias datecalc=./datecalc
year=$1
month=$2
day=$3
dow=$(datecalc -d $year $month $day)
mjd=$(datecalc -j $year $month $day)

(( mjd2=mjd-(dow+1) ))
(( mjd1=mjd2-6 ))

datecalc -j $mjd1
datecalc -j $mjd2
exit 0
$
$
$ ./last-week 2011 5 1
dow = 0
2011 4 24
2011 4 30
$

# 3  
Old 05-05-2011
Are you trying to generate filenames which contain a date?

Assuming that this is a process which is going to run week-on-week fiirst impressions are that this may be easier if you have a daily cron at say 23:58 which finds and appends that days filenames in a filelist file. At say 23:59 on the last day of the week have another cron which renames filelist as filelist.lastweek and nulls filelist ready for the new week. Then the following Thursday you have a filelist.lastweek ready to use.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Automated File Transfer Script

We are receiving data feed files in SFTP location daily. so the folder structure in SFTP location is abc/def/studyname_1/outbound/zipped files So we will be getting different studies and for each study a folder is created abc/def/studyname_2/outbound/zipped files , ... (7 Replies)
Discussion started by: Sidhant
7 Replies

2. Shell Programming and Scripting

How to make script for file transfer?

Hi All, Please suggest me how to make script for file transfer from server X to another server Y. I have some directory path in server X as below: /home/directory_1/ . . /home/directory_n/ where some text files are available in each directory where some files records zero and some files... (6 Replies)
Discussion started by: aaditya321
6 Replies

3. AIX

Problem using scp to transfer a file

I am testing the following command to transfer a file from my server (AIX 5.2) to another server. I was able to generate the keys and sent them the public key. scp -v -P 4030 /home/lawson/.ssh/jimtest.txt someuser@some.ftpsite.net:/Inbound/jimtest.txt > jimtest_out.txt 2>&1 Based on... (3 Replies)
Discussion started by: jyoung
3 Replies

4. Shell Programming and Scripting

File transfer script

Hi, I need a shell script to transfer a file from one server(unix box) to another server(windows box). I have the details of the source and destination Ip's. source path : /home/UNIX/server filename:abc.txt Destination folder: D:/UNIX/test I am using AIX server. Type of shell :... (1 Reply)
Discussion started by: NareshN
1 Replies

5. Shell Programming and Scripting

Expect script file transfer failure

I use expect to spawn an sftp file transfer. On occasion the transfer fails or doesn't complete correctly, resulting in: "sftp> cd /returns sftp> rename /returns/TESTFILE.TXT /returns/archive/TESTFILE.TXT Couldn't rename file "/returns/TESTFILE.TXT" to "/returns/archive/TESTFILE.TXT": Failure... (0 Replies)
Discussion started by: tjb1959
0 Replies

6. UNIX for Dummies Questions & Answers

Problem automating sFTP transfer using script in cron

Hi Newbie here I am having problems with automating sFTP transfers. Just to save time - SCP is not an option as sFTP is stipulated by controllers of far end server. Ineed to automate sFTP transfer of a single file, once a day to a remote server to which i have no control over. I am using:... (6 Replies)
Discussion started by: robbien
6 Replies

7. UNIX for Advanced & Expert Users

problem while doing Large file transfer thru Scp and FTP

Hi , I want to transfer one file having 6GB(after compression) which is in .cpk format from one server to other server. I tried scp command as well as FTP and also split the file then transfer the files thru scp command. At last i am facing the data lost and connection lost issue. Generally it... (2 Replies)
Discussion started by: Sumit sarangi
2 Replies

8. Programming

Problem in file transfer using sockets

Hai Friends I am writing a c program to transfer files from one system to another using TCP/IP socket programming.. My Recieve Program #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> extern int errno; extern char *sys_erlist; void... (2 Replies)
Discussion started by: collins
2 Replies

9. UNIX for Dummies Questions & Answers

Have problem transfer large file bigger 1GB

Hi folks, I have a big problem.... and need help from your experience/knowledge. I previously install and use FREEBSD 7.0 release on my storage/backup file server, for some reason, I can not transfer any files that is bigger than 1GB. If I transfer it to Freebsd file server, the system... (2 Replies)
Discussion started by: bsdme2
2 Replies

10. UNIX for Advanced & Expert Users

Large file transfer problem

Hello Everyone, I can't transfer a large file (~15GB TAR Archive) from one linux machine to another via FTP. I have tried the following: 1) Normal FTP the whole 15GB. This stops when it gets to about 2GB and doesn't go any further. 2) Split the 15GB file into 500MB pieces using the... (1 Reply)
Discussion started by: VVV
1 Replies
Login or Register to Ask a Question