Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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/ user@host

while my has this

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

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


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

share|improve this question

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


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.