Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

backslash problems

Status
Not open for further replies.

blunte

Programmer
Joined
Feb 18, 2003
Messages
2
Location
US
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
 
Update... sometimes when things are particularly confusing, it's easy to overlook an obvious mistake.

My sample code would have worked if I had put a ":" after the nextLetter (ie, E: )

My problem is apparently solved now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top