¿ªÔÆÌåÓý

Locked Writing to a file from Jython Script #scripting


 

I want to write into a file from a jython script. I get Errno 13 Permission Denied.
?
This is on Windows 11 but despite setting windows permissions to Everyone Read/Write its still not interested. Appreciate that this is probabley more of a windows question but has anyone manged to do this?
?
f = open("c:\a\demofile2.txt", "a")
f.write("This should be displayed")
f.close()
?
Thanks


 

I deeply mistrust the location you are trying to use. Try doing this in a directory within your own windows user profile, and make sure that the directory you want to create the file in is writable.

Wouter


On Mon, 9 Sept 2024 at 10:03, John H via <johnhastie=[email protected]> wrote:
I want to write into a file from a jython script. I get Errno 13 Permission Denied.
?
This is on Windows 11 but despite setting windows permissions to Everyone Read/Write its still not interested. Appreciate that this is probabley more of a windows question but has anyone manged to do this?
?
f = open("c:\a\demofile2.txt", "a")
f.write("This should be displayed")
f.close()
?
Thanks


 

¿ªÔÆÌåÓý

John,

Does the folder c:\a exists?

> despite setting windows permissions to Everyone Read/Write

JMRI runs with the same permissions as yourself so if you have created the folder c:\a , you should not need to set any permissions.

Daniel

On 2024-09-09 11:03, John H wrote:

I want to write into a file from a jython script. I get Errno 13 Permission Denied.
?
This is on Windows 11 but despite setting windows permissions to Everyone Read/Write its still not interested. Appreciate that this is probabley more of a windows question but has anyone manged to do this?
?
f = open("c:\a\demofile2.txt", "a")
f.write("This should be displayed")
f.close()
?
Thanks


 

Try using a path within your home directory.

C:\Users\<username>\demofile2.txt

Dave Sand


----- Original message -----
From: John H <johnhastie@...>
Subject: [jmriusers] Writing to a file from Jython Script
Date: Monday, September 09, 2024 4:03 AM

I want to write into a file from a jython script. I get Errno 13 Permission Denied.
?
This is on Windows 11 but despite setting windows permissions to Everyone Read/Write its still not interested. Appreciate that this is probabley more of a windows question but has anyone manged to do this?
?
f = open("c:\a\demofile2.txt", "a")
f.write("This should be displayed")
f.close()
?
Thanks