# Python FTP

**URL:** <https://forum.inductiveautomation.com/t/python-ftp/9305>\
**Category:** Ignition\
**Created:** [November 7, 2014, 5:55pm UTC](https://forum.inductiveautomation.com/t/python-ftp/9305 "2014-11-07T17:55:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbackus](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tbackus/32/5091_2.png) [@tbackus](https://forum.inductiveautomation.com/u/tbackus)\
**Post date:** [November 7, 2014, 5:55pm UTC](https://forum.inductiveautomation.com/t/python-ftp/9305/1 "2014-11-07T17:55:55Z")

</div>

I have a need to upload a text file to a printer at the touch of a button…

This is the script behind the button…

`import os
import system
import ftplib
filename = "\\\BRPAAPP001\zebra\\bufferclearlable.txt"
print filename
if system.tag.read("PRT_Select/PrinterSelected").value == 1:
	ftp = ftplib.FTP("10.155.3.111")
else:
	ftp = ftplib.FTP("10.155.3.112")
ftp.login("ignition")
myfile = open(filename, 'r')
ftp.storlines('STOR ' + filename, myfile)
myfile.close()
ftp.quit()
`

I cannot seem to get the filename set correcty with the slashes. Can someone help me?

---

<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:** [November 7, 2014, 7:58pm UTC](https://forum.inductiveautomation.com/t/python-ftp/9305/2 "2014-11-07T19:58:14Z")

</div>

Are you looking for a double backslash at the beginning?

```auto
filename = "\\\\BRPAAPP001\\zebra\\bufferclearlable.txt"
```

Out of curiosity, is this going to a print server?

---

<div class="post-metadata">

**Author:** ![tbackus](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tbackus/32/5091_2.png) [@tbackus](https://forum.inductiveautomation.com/u/tbackus)\
**Post date:** [November 7, 2014, 8:02pm UTC](https://forum.inductiveautomation.com/t/python-ftp/9305/3 "2014-11-07T20:02:44Z")

</div>

No dice…

Traceback (most recent call last):  
File “event:actionPerformed”, line 10, in   
IOError: (2, ‘No such file or directory’, ‘\\BRPAAPP001\zebra\bufferclearlable.txt’)

Its s Zebra Printer, so they are a bunch of ZPL commands to clear the buffer and then print a label indicating that the buffer is clear…

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [November 7, 2014, 8:03pm UTC](https://forum.inductiveautomation.com/t/python-ftp/9305/4 "2014-11-07T20:03:57Z")

</div>

Try adding an r

```auto
filename = r"\\BRPAAPP001\zebra\bufferclearlable.txt"
```

---

<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:** [November 7, 2014, 8:20pm UTC](https://forum.inductiveautomation.com/t/python-ftp/9305/5 "2014-11-07T20:20:17Z")

</div>

I seem to remember reading about using PUT instead of STOR. Just can’t quite remember.

Also, you can try using an FTP client like FileZilla to test transfers before scripting.

---

<div class="post-metadata">

**Author:** ![tbackus](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tbackus/32/5091_2.png) [@tbackus](https://forum.inductiveautomation.com/u/tbackus)\
**Post date:** [November 7, 2014, 10:57pm UTC](https://forum.inductiveautomation.com/t/python-ftp/9305/6 "2014-11-07T22:57:20Z")

</div>

Thanks Jordan, I have tested manual transfers… I can do the transfer fine from my laptop in python and it works just fine, unfortunately when I move it to Ignition is where I start getting the errors.

---

<div class="post-metadata">

**Author:** ![pdibenedetto](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pdibenedetto/32/6364_2.png) [@pdibenedetto](https://forum.inductiveautomation.com/u/pdibenedetto)\
**Post date:** [November 8, 2014, 12:07am UTC](https://forum.inductiveautomation.com/t/python-ftp/9305/7 "2014-11-08T00:07:56Z")

</div>

Be aware that you are using Jython and not CPython in Ignition. You are trying to open a file from a network path. Java and windows network paths doesn’t work in a easy way.

Before doing the FTP thing, be sure that you can reach that file from network location.

Try to get the content of the file and printing in the console using [support.inductiveautomation.com … string.htm](https://support.inductiveautomation.com/usermanuals/ignition/system_file_readfileasstring.htm)

For configuring network path to access in Ignition, see:  
[support.inductiveautomation.com … \_drive.htm](https://support.inductiveautomation.com/usermanuals/ignition/mapping_a_network_drive.htm)

I hope this help. Regards,
