Howdy.
I'm having a really hard time dealing with backslashes in a win32 utility I'm making.
Here's a code snippet:
nextLetter = getNextAvailableLetter()
newdrive = "\\\\myserver\\myshare"
print "newdrive = [" + newdrive + "]"
system("cmd /c net use " + nextLetter + " " + newdrive)
The system call fails, and I believe it's because the drive text is getting messed up. I've tried using "\\myserver\myshare", re.escape(newdrive), raw(newdrive), and everything else I could imagine.
The print line always looks fine, either as \\\\ or \\ (depending on which I tried), but nothing works on the system call.
Interestingly enough, if I do the same thing in Python Interactive Shell, it works.
>>> blah = r'\\myserver\myshare'
>>> system("cmd /c net use e: " + blah)
The command completed successfully.
0
Any suggestions?
Thanks much.
MT
I'm having a really hard time dealing with backslashes in a win32 utility I'm making.
Here's a code snippet:
nextLetter = getNextAvailableLetter()
newdrive = "\\\\myserver\\myshare"
print "newdrive = [" + newdrive + "]"
system("cmd /c net use " + nextLetter + " " + newdrive)
The system call fails, and I believe it's because the drive text is getting messed up. I've tried using "\\myserver\myshare", re.escape(newdrive), raw(newdrive), and everything else I could imagine.
The print line always looks fine, either as \\\\ or \\ (depending on which I tried), but nothing works on the system call.
Interestingly enough, if I do the same thing in Python Interactive Shell, it works.
>>> blah = r'\\myserver\myshare'
>>> system("cmd /c net use e: " + blah)
The command completed successfully.
0
Any suggestions?
Thanks much.
MT