0

Need to transfer a file, rename it and close the connection for each file where I have multiple files using sftp.

Server A - Source Server B - destination

I need to transfer files form server A to server B using sftp Sample files on the server A - local_file001-100

Path on sever A - /data/sftp Path on server B - /home/local/sftpuser This is what I have come up with, which transfers the file and renames it to todays_local_file but does not close the connection after each file transfer. I have a requirement which needs connection terminated after each file transfer and reconnect for the next one.

sftp sftpuser@xyz.server.com:/home/local/sftpuser <

  • 1
    Possibly, but we will need more details. Please edit your question and tell us where you get the file names from, where you want to copy them, why you need to close the connection after each transfer(!), how we can know what files you want to copy, how to name them, where to copy them. We need to know what you are doing to be able to help you. Show us what you have so far and explain what you need help with. – terdon Feb 27 at 20:14
  • The question is looking much better after your edits. What should the files be renamed to? How can we determine how they will be renamed? You also haven't clarified why the connection must be terminated after each transfer. – Crypteya Feb 27 at 22:41
  • 1
    It can be renamed to new_local_file (sorry about not mentioning earlier). So we have a client who has been using crushftp application which uses the mechanism of transferring the file, rename and disconnect for each file. So, now they have been having issue after 9 file transfer from the application. I am trying to reproduce the same scenario and try from default rhel 7 to sftp server(rhel7). Trying to figure out if it an issue from application or redhat system. – Surya Feb 27 at 22:53
  • @Crypteya - Would you be able to help me with the script? – Surya Mar 6 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.