I have a NodeJS project that I’m having call a Python script which simply makes a new directory in a remote file storing network (a UNC path).
However, when I try to use os.mkdir
in the Python, it seems that on the server-side, the Node doesn’t want to escape the ” characters, meaning it’s trying to create a directory "\myserver.comfolder1newFolder"
instead of "myserver.comfolder1newFolder"
Code:
NodeJS:
var pyshell = new PythonShell('mkdir.py', {scriptPath:"/path/toScript"}); //Calls python script (works well)
Python:
import os
import sys
print("SCRIPT CALLED") #Test that .py file is being called
os.mkdir("\myserver.comfolder1newFolder")
Output (on server):
SCRIPT CALLED #Shows script is being called properly, as print method is showing
Error: OSError: [Errno 71] Protocol error: '\myserver.comfolder1newFolder'
File "/home/mkdir.py", line 8, in <module>
os.mkdir("\myserver.comfolder1newFolder")
My best guess here based on the error is that it’s not escaping the characters when trying to make the directory. Any insight? I’d really appreciate any help.
Source: Ask Javascript Questions