# Scripting question

**URL:** <https://forum.inductiveautomation.com/t/scripting-question/109604>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [August 11, 2025, 7:02pm UTC](https://forum.inductiveautomation.com/t/scripting-question/109604 "2025-08-11T19:02:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [August 11, 2025, 7:02pm UTC](https://forum.inductiveautomation.com/t/scripting-question/109604/1 "2025-08-11T19:02:08Z")

</div>

How would I go about doing file IO in a project library script?

`import os `  
`print(os.getcwd()) `  
`with open(os.getcwd() + "\\testfile.txt", "w+") as file:`  
` file.write("test")`

This doesn’t work, it gives me errno13, so does trying to directly write to my desktop

---

<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:** [August 11, 2025, 7:09pm UTC](https://forum.inductiveautomation.com/t/scripting-question/109604/2 "2025-08-11T19:09:21Z")

</div>

> [@Leor\_Fishman](#):
>
> in a project library script?

Why do you ask this specifically? (The project library has no scope–functions there run in the caller’s scope.)

I suspect you’ve lost track of what JVM is running your code.

FWIW, for best results, use java’s I/O libraries, not jython’s.

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [August 11, 2025, 7:15pm UTC](https://forum.inductiveautomation.com/t/scripting-question/109604/3 "2025-08-11T19:15:00Z")

</div>

Perspective scope/gateway scope, mostly just out of curiosity as I familiarize myself with scripting. In particular I was trying this from the script console, and I also tried just purely running the relevant code in that script console

---

<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:** [August 11, 2025, 7:19pm UTC](https://forum.inductiveautomation.com/t/scripting-question/109604/4 "2025-08-11T19:19:12Z")

</div>

A Perspective script is not going to be able access your desktop unless

1. You’re running your session on your gateway, and
2. You’ve made security changes to allow the gateway service to access your files, and
3. The path in your script is absolute

The designer script console is **Vision** scope. I’m very sure you’ve heard this before. ☹

---

<div class="post-metadata">

**Author:** ![Leor\_Fishman](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@Leor\_Fishman](https://forum.inductiveautomation.com/u/Leor_Fishman)\
**Post date:** [August 11, 2025, 7:20pm UTC](https://forum.inductiveautomation.com/t/scripting-question/109604/5 "2025-08-11T19:20:01Z")

</div>

Ah, yep, that’d do it, thanks!
