Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have to setup with the banking interface where I need to connect to the remote bank and then download the files in the bank server in-box to my local server for further processing

so i do following sftp commands in the crontab

sftp -b /usr/local/CoXXX/inbox/get.sh user@host

while my get.sh has this

cd CoXX/inbox
get ^DELIST*
get ^BPAY*
bye

however my requirement is to after i download the file i need to rename that file in the server to D-(SAME FILE NAME), just adding a D- identify the its has been already processed.

how to i do that if i do

rename DELIST* D-DELIST*

i think it will rename all files (not the file that has been downloaded) how do i archive this ?

share|improve this question

1 Answer 1

If you don't want to go down the route of retrieving a list of files first (ls in sftp batch) and then processing them with individual transfers, renaming them one by one as they arrive, I'd work with inotify-tools. Whenever a write completes (file is downloaded) into your target directory, trigger a script to rename it.

share|improve this answer
    
is there a way to do this "one by one" using ls command i am a developer i dont have much knowledge about the shell commands ... i think best ways is to once the file is downloaded is confirmed exeucte the rename in the server side but to do this i need to know that download has completed, how do i do that should i use some | pipe into commands ? –  user1179459 Oct 17 '12 at 2:25
    
It's up to you to parse 'ls' output as returned by your batch-job, and then act on it. But I'd really recommend using inotify for this. man inotifywatch , man inotifywait –  tink Oct 17 '12 at 3:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.