# Reading sftp files

**URL:** <https://forum.inductiveautomation.com/t/reading-sftp-files/33757>\
**Category:** Ignition\
**Created:** [April 7, 2020, 7:45pm UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757 "2020-04-07T19:45:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveD24](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@DaveD24](https://forum.inductiveautomation.com/u/DaveD24)\
**Post date:** [April 7, 2020, 7:45pm UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757/1 "2020-04-07T19:45:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [April 7, 2020, 10:25pm UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757/2 "2020-04-07T22:25:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [April 8, 2020, 1:39am UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757/3 "2020-04-08T01:39:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DaveD24](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@DaveD24](https://forum.inductiveautomation.com/u/DaveD24)\
**Post date:** [April 8, 2020, 10:59am UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757/4 "2020-04-08T10:59:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 8, 2020, 11:20am UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757/5 "2020-04-08T11:20:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [April 8, 2020, 11:47am UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757/6 "2020-04-08T11:47:14Z")

</div>

Are all the meters the same brand, what brand?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 8, 2020, 12:13pm UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757/7 "2020-04-08T12:13:23Z")

</div>

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.

> <https://stackoverflow.com/questions/15108923/sftp-file-transfer-using-java-jsch>

---

<div class="post-metadata">

**Author:** ![DaveD24](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@DaveD24](https://forum.inductiveautomation.com/u/DaveD24)\
**Post date:** [April 8, 2020, 1:10pm UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757/8 "2020-04-08T13:10:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![DaveD24](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@DaveD24](https://forum.inductiveautomation.com/u/DaveD24)\
**Post date:** [April 8, 2020, 1:14pm UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757/9 "2020-04-08T13:14:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 8, 2020, 1:44pm UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757/10 "2020-04-08T13:44:23Z")

</div>

> [@DaveD24](#):
>
> where I get the JSch library

Let me [Google That For You](https://www.google.com/search?q=JSch).

> [@DaveD24](#):
>
> where I put this on the gateway

> [@Adding java custom classes to Ignition](http://forum.inductiveautomation.com/t/adding-java-custom-classes-to-ignition/15202/2):
>
> The only way to do this is to drop your jar files into the lib/core/gateway, lib/core/client, lib/core/designer, or lib/core/common folders, depending on the scope you want to be able to access them in. Putting them in common should make them available everywhere. The downside is that these are not part of the backup or preserved in any way, so you need to make sure your jars are always added to those locations in new gateways, etc… on your own. disclaimer: this is not officially supported and …

> [@DaveD24](#):
>
> also will I need to restart the gateway?

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

---

<div class="post-metadata">

**Author:** ![DaveD24](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@DaveD24](https://forum.inductiveautomation.com/u/DaveD24)\
**Post date:** [April 8, 2020, 6:17pm UTC](https://forum.inductiveautomation.com/t/reading-sftp-files/33757/11 "2020-04-08T18:17:07Z")

</div>

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
```
