File transfer from one directory to another directory in unix


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File transfer from one directory to another directory in unix
# 1  
Old 11-02-2009
Question Need Some Logic Help in File transfer from one directory to another directory in UNIX

Hi,
I have to transfer five files from one directory to another directory in unix with the help of shell scripts. This shell script calling the param file as input parameter. Every day one file will come and fall on my source directory. Remaining files will fall on any one of the day of the month. My existing script will transfer on every day. Proposed system will transfer the file on cyclic base (whenever the four files fall on my source directory). I can't specify the those four files name on my script because this script for generic purpose. I am giving the sample data of my param file below

n1 N1.filename1 data01 N1.filename1
n1 N1.filename2 data01 N1.filename2
n1 N1.filename3 data01 N1.filename3
n1 N1.filename4 data01 N1.filename4
n1 N.dailyfile data01 N.dailyfile

How can i achive the transfer. Can u help me.

Thanks,
A. Easter raj

Last edited by easterraj; 11-02-2009 at 12:44 PM.. Reason: not so clear
# 2  
Old 11-02-2009
Not so clear...

Also, what you have tried so far ! Post that also.
# 3  
Old 11-02-2009
Do you mean that until all four files are present, you don't want to copy them?

Do they get deleted after copy (which means you really want to move them) or does the script need to distinguish which four files belong together by some other means?
# 4  
Old 11-02-2009
Quote:
n1 N1.filename1 data01 N1.filename1
n1 N1.filename2 data01 N1.filename2
n1 N1.filename3 data01 N1.filename3
n1 N1.filename4 data01 N1.filename4
n1 N.dailyfile data01 N.dailyfile
Please explain what the fields mean in your "param file" and whether the "param file" is supplied or derived?
If you were to do the job manually without a script, what would you type?
# 5  
Old 11-03-2009
Quote:
Originally Posted by TonyLawrence
Do you mean that until all four files are present, you don't want to copy them?





Do they get deleted after copy (which means you really want to move them) or does the script need to distinguish which four files belong together by some other means?

Yes untill all four files are present I dont want to copy them
# 6  
Old 11-03-2009
Hi,

infile ---> input file which contains the list of files to check.
indir ----> directory where the file comes in
newdir --> directory where the file needs to be transfered

Put the below script dirtransfer.ksh in the cron and set to check every 1 hour, everyday.

Code:
 
# more infile
N1.filename1
N1.filename2
N1.filename3
N1.filename4
N.dailyfile
#
#
# more dirtransfer.ksh
#!/bin/ksh
set -x
DIRNAME='indir'
NEWDIRNAME='newdir'
count=0
while read line
do
        if [ -f $DIRNAME/$line ]
        then
                count=`expr $count + 1`
        fi
done < infile
if [ $count -eq 5 ]
then
        mv $DIRNAME/* $NEWDIRNAME
fi

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

2. UNIX for Dummies Questions & Answers

Extract directory name from the full directory path in UNIX using shell scripting

My input is as below : /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt /splunk/scrubbed/loyal/IFIND.HELLO.WROC.txt /splunk/scrubbed/triumph/ifind.triumph.txt From the above input I want to extract the file names only . Basically I want to... (5 Replies)
Discussion started by: IshuGupta
5 Replies

3. Shell Programming and Scripting

How to transfer file from Local PC to UNIX Directory without FTP?

Dear All, i am trying to get the file from windows location to unix location without using FTP and neither thru entering the user id and password. I have one unix form which is running on web application and user is entering the location and file name there now i know the file name and path. So i... (8 Replies)
Discussion started by: ripudaman.singh
8 Replies

4. Shell Programming and Scripting

Grepping file names, comparing them to a directory of files, and moving them into a new directory

got it figured out :) (1 Reply)
Discussion started by: sHockz
1 Replies

5. UNIX for Dummies Questions & Answers

How to transfer file from Local PC to Unix Directory without FTP!!!

Dear Friends, How to transfer files from my local PC to Unix directory without using FTP. Scenario: Transfer/Upload a file from PC to unix using web browser without using FTP technologies. I heard something like sendunix and sendpc used to transfer files from unix to Desktop and... (1 Reply)
Discussion started by: kk_c2il2
1 Replies

6. Shell Programming and Scripting

Checking directory permissions on UNIX directory

Hi, How do i check if I have read/write/execute rights on a UNIX directory? What I'm doing is checking read access on the files but i also want to check if user has rights on the direcory in whcih these files are present. if then...... And I check if the directory exists by using... (6 Replies)
Discussion started by: chetancrsp18
6 Replies

7. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies

8. IP Networking

How to Transfer a whole Directory from unix to windows using FTP?

Hi I can transfer a single file and multiple file from unix to widows using get and mget command.But i dont know How to transfer a whole directory from unix to windows using command. pls help me Ramkumar (1 Reply)
Discussion started by: ramkumarm83
1 Replies

9. UNIX for Dummies Questions & Answers

moving files from a unix directory to a windows directory

Any body any ideas i'm failry new to this so any help would be appreciated. Cheers Steve (2 Replies)
Discussion started by: gleads
2 Replies

10. UNIX for Dummies Questions & Answers

Directory file transfer...help

I'm a real newbie, and I'm stuck trying to ftp download a directory and all contained files/directories. I'm using mget but I have to create all the directories locally first (pain). How else can I do it withing the ftp command. Apologies for sound stupid but we all gotta start somewhere. ... (2 Replies)
Discussion started by: ian
2 Replies
Login or Register to Ask a Question