# Retrieve script from script console

**URL:** <https://forum.inductiveautomation.com/t/retrieve-script-from-script-console/45607>\
**Category:** Ignition\
**Created:** [April 14, 2021, 7:10pm UTC](https://forum.inductiveautomation.com/t/retrieve-script-from-script-console/45607 "2021-04-14T19:10:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hventer23](https://avatars.discourse-cdn.com/v4/letter/h/bbce88/32.png) [@hventer23](https://forum.inductiveautomation.com/u/hventer23)\
**Post date:** [April 14, 2021, 7:10pm UTC](https://forum.inductiveautomation.com/t/retrieve-script-from-script-console/45607/1 "2021-04-14T19:10:54Z")

</div>

I accidentally closed the script console while it had a large script in it that took me a few hours to write and test. Is there a way to retrieve it? Rookie mistake…

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 14, 2021, 7:28pm UTC](https://forum.inductiveautomation.com/t/retrieve-script-from-script-console/45607/2 "2021-04-14T19:28:08Z")

</div>

Did you close the Designer in between then and now? When I open the Script Console it usually has the last code I wrote/executed in it.

---

<div class="post-metadata">

**Author:** ![hventer23](https://avatars.discourse-cdn.com/v4/letter/h/bbce88/32.png) [@hventer23](https://forum.inductiveautomation.com/u/hventer23)\
**Post date:** [April 14, 2021, 7:32pm UTC](https://forum.inductiveautomation.com/t/retrieve-script-from-script-console/45607/3 "2021-04-14T19:32:06Z")

</div>

Yes…I closed the whole designer unfortunately. Is there no log file somewhere that logs scripts that were run from the python script console? I ran the code multiple times in its finished state.

---

<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 14, 2021, 7:43pm UTC](https://forum.inductiveautomation.com/t/retrieve-script-from-script-console/45607/4 "2021-04-14T19:43:03Z")

</div>

No, no such logging. The script console is pretty ephemeral, much like the DB Query browser.

---

<div class="post-metadata">

**Author:** ![hventer23](https://avatars.discourse-cdn.com/v4/letter/h/bbce88/32.png) [@hventer23](https://forum.inductiveautomation.com/u/hventer23)\
**Post date:** [April 14, 2021, 7:49pm UTC](https://forum.inductiveautomation.com/t/retrieve-script-from-script-console/45607/5 "2021-04-14T19:49:41Z")

</div>

That’s a bummer. But thanks for the help guys. The response here is fast.

---

<div class="post-metadata">

**Author:** ![liam.mcglaughlin](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@liam.mcglaughlin](https://forum.inductiveautomation.com/u/liam.mcglaughlin)\
**Post date:** [January 12, 2022, 10:22pm UTC](https://forum.inductiveautomation.com/t/retrieve-script-from-script-console/45607/6 "2022-01-12T22:22:22Z")

</div>

This is from a while back, but I remembered having read it when I put together a simple function to save a copy of the code in the script console to a file when you run it. Put it in a shared module and call it at the top of the code.

More than once I’ve managed to lock up the designer with a loop or too much data in memory and lose my work. So, this has been at the back of my mind for a couple of years now.

Putting it here in case anyone would find it useful.

> <https://github.com/HelloMorrisMoss/Ignition/blob/master/console.py>

---

<div class="post-metadata">

**Author:** ![hventer23](https://avatars.discourse-cdn.com/v4/letter/h/bbce88/32.png) [@hventer23](https://forum.inductiveautomation.com/u/hventer23)\
**Post date:** [January 13, 2022, 9:15am UTC](https://forum.inductiveautomation.com/t/retrieve-script-from-script-console/45607/7 "2022-01-13T09:15:27Z")

</div>

Thank, this is a great script to have.
