cancel
Showing results for 
Search instead for 
Did you mean: 

SFTP adapter OS level command

Former Member
0 Kudos

Hello,

I am having File to SFTP interface , a simple copy with and hence no ESR content and using ASMA for filename. However the trick is that, the files that are generated from the application doesn't have any extension (tried different configurations in that system but no use) and the target application expects a file with extension say abc.txt.

Hence I tried to use OS level command both in File Sender (before message processing) and in SFTP receiver (after message processing). I tried with

mv %F %F.txt command in SFTP receiver adapter considering %F as FQDN path, however it seems it is trying to rename the file locally rather than on SFTP server.

Has anybody tried the same. Please let me know. I am just trying to avoid extra piece of work to create a java mapping to read DynamicConfiguration and change filename there.

Regards

Accepted Solutions (0)

Answers (1)

Answers (1)

Ryan-Crosby
Active Contributor
0 Kudos

Hi Ameet,

Try %f instead of %F - that should represent the file name while %F is for the path of the file.

Regards,

Ryan Crosby

Former Member
0 Kudos

Tried the same but again it seems it is trying to find locally rather than on SFTP server.

Regards

Ryan-Crosby
Active Contributor
0 Kudos

Hi Ameet,

Do you have some indication in the logs that it is trying to find it locally vs. in the file system of the SFTP server?  Can you share that information?

Regards,

Ryan Crosby

Former Member
0 Kudos

Yes Ryan. Actually I could see the command in the logs say mv <filename> <filename>.txt getting completed successfully, however when checked in SFTP server, the file is not renamed.

Actually it seems we need to give something like a sftp command in single line to achieve so.

Regards

Ryan-Crosby
Active Contributor
0 Kudos

Hi Ameet,

If you login to a shell with the user that is used for the CC are you able to execute that same command (Assuming Linux/Unix OS)?  That would be a test to run to ensure the command will run successfully after the file has been written.

Regards,

Ryan Crosby

Former Member
0 Kudos

Hi Ryan,

I was able to frame a command, something like

sftp -oIdentityFile=<identity filepath>_-oPort=<sftp port> <sftp user>@<sftp host> <<< $'rename %F  %F.txt'.

but this was not working since we found that PI server uses C-Shell and this command is not supported by the same. Instead I use more cleaner method and used DynamicConfigurationBean to write the value of ASMA to message.interface message attribute and replace the same using Variable Substitution technique.

Regards