Reading sftp files

Anyone have any ideas on how to read files and directories over sftp in Ignition, we have a bunch of power meters that record power disturbance wave-forms and make that data available via sftp, I have tried to use Python libs: pysftp & paramiko, but after downloading several dependencies, one was C-Python only, if this is not possible in Python, is there any thing available in Java, if Java is the answer an example of how read a directory and a file would appreciated.

Your best bet for stability/performance is probably a Java package, but the only supported way to make one available (we don’t bundle one already in the software) is to build a custom module.

I had to fool with sftp a while back. luckily someone much smarter than me with this type of process had already had something setup with psftp(putty sftp) to connect to the sftp site and move the files TO the site. I worked with what he had and used Ignition to run bat files that issued the relevant sftp commands to perform what i needed. Just throwing an alternate out there. You could always write bat files to pull the data and store it locally where you could then process it. My use case was moving to a sftp server, but I am sure you could move from just as easily. Works great on my end, have never had a failure.

Thanks for the feedback, I done some testing today with the Linux equivalent of the BAT file(driving the sftp command via expect) and it works fairly well, it answers the password and certificate questions, then down loads the file or directory listing.

Given that Ignition is written Java and runs secure communications, I am surprised we can’t import some of those Classes into Python?

Java doesn’t natively support sftp. This is why Paul mentioned that the supported way is to build a module.

Are all the meters the same brand, what brand?

It seems that JSch is your in-Java solution. You’ll have to drop it in your gateway’s jar folder or package it in a module.

1 Like

This sounds promising, could you advise where I get the JSch library and where I put this on the gateway, there seems to several folders with .jar files in them, this a Ubuntu 18:04 installation, also will I need to restart the gateway?

They are Schneider PM8240 meters, there will be some older ION7650 types too, but they used normal FTP, so can read them with Python ftplib.

Let me Google That For You.

If dropping a jar into a gateway folder as above, yes. If packaging in a module, no.

3 Likes

Thank you all for you input, for maintenance and compatibility purposes I think I will have run with the OS script to get those files on to the gateway.

       Appreciate the feedback