I am trying to write a Python script that can move and copy files on a remote Linux server. However, I cannot assume that everyone who runs the script (on Windows) will match this server with the same letter. Instead of offering users the correct email, I just want to access the server by its network URL, to which the drive letter is mapped. So for example, if I matched the server url
\\name-of-machine.site.company.com
To be an S: \ drive, I want to access, say, the S: \ var \ SomeFile.txt file in agnostic form of the drive. I looked around, and the general recommendation seems to be to use UNC notation:
f = open(r"\\name-of-machine.site.company.com\var\SomeFile.txt", "w")
But if I try to do this, IOError says that there is no such file or directory. If I try to use the server IP address instead (not a real address, but similar):
f = open(r"\\10.1.123.149\var\SomeFile.txt", "w")
After a long pause, I get an IO error message: "Invalid mode (" w ") or file name." Why don't these notations work, and how can I access this server (ideally, like a local disk) using its URL?
source share