netbox custom script - csv file permission denied #15526
Unanswered
nikunj-tele
asked this question in
Help Wanted!
Replies: 1 comment 2 replies
-
As the error quite clearly says, this is a permissions problem. Your custom script can only write to directories which are owned by the "netbox" user (i.e. it's not a problem with the file, it's the directory you're trying to write to) But in this case there's no need to write to any file on the server. Just get your custom script to return the CSV as a string, by using StringIO, and the user will get it in their browser. There's an example custom script here which you can copy. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi All,
I have written the script to generate the inventory output but when I tried to download this output in csv file it gives the following error , my script is working fine if it generate the output but only csv failed
An exception occurred: PermissionError: [Errno 13] Permission denied: 'netbox_custom_inventory.csv'
Traceback (most recent call last):
File "/opt/netbox/netbox/extras/scripts.py", line 504, in _run_script
script.output = script.run(data=data, commit=commit)
File "/opt/netbox/netbox/scripts/netbox-invscript.py", line 32, in run
with open(OUTPUT_FILE, "w", newline="") as csvfile:
PermissionError: [Errno 13] Permission denied: 'netbox_custom_inventory.csv'
snippest of the code is as below
please ignore wrong indentation as coping code messed it.!
Unfortunately , I donot have access on the production server to create and change the ownership/permission of the csv file.
Is there any way to write the output into the csv file and download it ?
is is possible to generate csv file using custom script ?
Thank you in advance.
Beta Was this translation helpful? Give feedback.
All reactions