Submitted byCategory
Review Cycle
.
Public
Joachim Mutter/sysarc
on 04/21/2020 at 02:37 PM
Excel

Excel VBA - Get File via SSH

A customer had daily data-files on a Unix based system and he looked for a simple solution to visualize this data.



A simple solution for this was an excel template, created statically out of the downloded (winscp) data from
this unix application and showing that in a line diagram. The problem here was, that we need SSH in VBA,
which you could buy as extension or using other complicated stuff, but if you have putty installed, there is a
simple solution via plist and pscp and the sehll() command to get the data.

Below is the code to get the newest file from a defined directory on a Unix system via VBA and load it into
your excel to show the results in a prepared diagram.

Main part is the code template which is modified by your parameters "host", "user" and "pwd" put into a
separate sheet and executed via thew Shell() command.

   cmd = "C:\tools\net\putty\plink.exe %USER%@%HOST% -pw %PWD% ls -l /tmp/*.dat>" + tmp + "\filelist.txt"