cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a file using python in exos

How to create a file using python in exos

Mateusz_Haba
New Contributor
Hi,

I'm trying to create a local file for writing and looks like I don't have a permission to do so.
I'm using custom created account but with admin privleges.

Is there any place in EXOS filesystem with write permissions?
1 ACCEPTED SOLUTION

Kawawa
Extreme Employee
You can use the open() function. I am using an admin account called pythonuser and running a pythong script that creates a file called thisFileWasCreatedWithPython.log.

code:
    fileName = "thisFileWasCreatedWithPython"
f = open('/usr/local/cfg/' + fileName + '.log', 'a')


I have RW permissions on the file after running my script:

code:
# ls *.log
-rw-r--r-- 1 admin admin 241770 Apr 11 21:29 thisFileWasCreatedWithPython.log


What version of EXOS are you using and can if you try the using the above in your script are you running into the same read only permission problem?

View solution in original post

2 REPLIES 2

Mateusz_Haba
New Contributor
Dunno why but I tried to create a file in /usr/local/cfg before and couldn't. I also tried at /usr/local/tmp but that didn't work either. Finally, I did it like this at /usr/local/cfg:

with open('test.xsf','w') as f:
f.write('something to file')

Thanks 

Kawawa
Extreme Employee
You can use the open() function. I am using an admin account called pythonuser and running a pythong script that creates a file called thisFileWasCreatedWithPython.log.

code:
    fileName = "thisFileWasCreatedWithPython"
f = open('/usr/local/cfg/' + fileName + '.log', 'a')


I have RW permissions on the file after running my script:

code:
# ls *.log
-rw-r--r-- 1 admin admin 241770 Apr 11 21:29 thisFileWasCreatedWithPython.log


What version of EXOS are you using and can if you try the using the above in your script are you running into the same read only permission problem?
GTM-P2G8KFN