0

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 ?

1 Answer 1

0

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.

2
  • 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 ?
    – mahen3d
    Oct 17, 2012 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, 2012 at 3:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .