[IPython-dev] Bug when launching dos commands

Jörgen Stenarson jorgen.stenarson at bostream.nu
Wed Oct 26 15:46:22 CDT 2005


I have found a problem with running dos commands (like dir) when my 
current directory is on a network share (UNC-path(I'm not sure what UNC 
means but cmd.exe complains about it)). The cmd.exe can not use UNC 
paths (paths beginning with \\). What happens is that the cmd.exe can 
not switch to the UNC address and instead ends up on some default 
directory on c:/, which means the command you issued will be performed 
in some other directory than you thought. Could be bad if your doing 
"del *.*"

So my workaround patches the shell command in genutils to temporarily 
switch the current directory to c: and then appending "pushd unc-path&&"
to the commandline string that is passed to os.system, and finally 
switch the work dir back to the unc-path. This is done if the os is 
windows and the workdir starts with \\

This works because "pushd UNC-path" mounts a network drive and then your 
path just becomes x:\.... and is thus not a UNC-path anymore.

This seems to work for me. But I'm not sure if this is the right place 
or the only place that need to change.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cmd_patch.txt
Url: http://projects.scipy.org/pipermail/ipython-dev/attachments/20051026/ca65260b/attachment.txt 

More information about the IPython-dev mailing list