cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting Particular filename from SFTP server

Former Member
0 Kudos

Hi All,

We have a requirement where we have File(NFS) to SFTP (username-Password authentication) scenario which will run once a day.

Client wants us to place file on target SFTP server with timestamp which is no issue.

The thing he wants SAP PI to do is to overwrite or we can say delete this file from target SFTP server before placing similar new file on next day.

So basically everyday before placing file on SFTP server I have to delete previous similar files present on target SFTP server.

I would like to avoid creating another configuration scenario for this requirement.

Though not sure but I think we can achieve this through some kind of script (.bat, powershell script) which can be placed on some AL11 path and then can be run in OS command line under processing tab in sender channel in "before processing" mode to check presence of file and deletion of same from SFTP server.

As I am new to scripts, will be thankful if someone can post sample script to "access and delete file from SFTP server" from a particular directory.

Let me know if you have solution to achieve same.

FYI: Our SAP PI server is a Windows server.

Regards

Saurabh

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184720
Active Contributor
0 Kudos

Hi Saurabh -

What kind of script you are looking for? Java? Perl? and i think you need custom libraries to work with SFTP.

Instead of executing the script from OS level, i would prefer a pass through interface which will pick the files from SFTP and place it somewhere else(archive directory)... You can even schedule this channel to run once in a day to delete the files.

Incase you still looking from some script.. i worked zehon and jcraft libraries and you can find some sample's here..

JSch - Java Secure Channel - Examples

zehon.com Java: SFTP Samples

former_member257758
Participant
0 Kudos

Hi Saurabh,

try using del *.* in (Run Operating System Command Before processing message ) SFTP Channel Properties and see.

Otheriwise try rm *.* as well

Thanks

Arun