Last December I wrote about how to use SFTP SSH from a Unix server, without using a Seeburger Adapter. SAP PI/XI cannot be used to access SSH SFTP sites directly, but this script can help. There have been many requests for a version which also works on windows. I do not have access to a windows server with PI or XI so it is a little difficult to test for me.
I have now written the following script, which works on my Vista labtop. I have not tested it on Windows 2003 or Windows 2008, where most PI systems will run.
I have used Putty for creating the SSH connection. I have used the pscp (an SCP client, i.e. command-line secure file copy). To try something different then using SFTP. SCP makes it easier to get files which should exist in a directory. Pscp should be downloaded and saved in the same directory as the script.
The script looks like the following.
REM %1 target file PI %F
REM %2 query for where the file is located ie. firstname.lastname@example.org:dir/*
REM %3 SSH Password
REM RESET the target file
echo '' >%1
IF EXIST %TARGETDIR% GOTO SKIPCREATEDIR
del /Q %TARGETDIR%\*
pscp.exe -pw %3 %2 %TARGETDIR%
type %TARGETDIR%\* > %1
The script takes the following parameters.
- The %F which is the name of the file, which the adapter is currently reading.
- A the location of the file on the server side in the form “user@server:path/[filter*] ie. email@example.com:dir/SKB*. This command logon with the user root on the host sftp.figaf.com. Then looks in the directory dir, relative to the login dir and the selects all files starting with SKB.
- The users password.
The command in the communication channel should look something like.
C:\scripts\sshftp.bat %F firstname.lastname@example.org:dir/SKB*.
I have only tested with password, but pscp might also work with using ssh keys.