Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Capture DOS error???

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


scook at elp

Jun 18, 2003, 10:41 PM

Post #1 of 4 (55 views)
Permalink
Capture DOS error???

I'm writing a script which at some point will map to a list of servers. The
program will be keeping a log of problems it encounters to be reviewed
later. To map the drive, I am using:

sDrive =
["B","F","G","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X"
,"Y","Z"]
iIndex = 0
shellCmd = ""
for s in sImage: # list of servers
shellCmd = "map " + sDrive[iIndex] + ":=" + s
iIndex=iIndex + 1
os.system(shellCmd)

My question is this...Is there a way to capture the DOS error it would
display if it had a problem mapping the server? I want to detect the
exception if there is one and write it to the log file. I have tried using
OSError, SystemError, and StandardError without success. I'm not
necessarily looking for someone to write the code for me as much as pointing
me in the right direction.

Thanks,


syver at inout

Jun 19, 2003, 3:29 AM

Post #2 of 4 (52 views)
Permalink
Capture DOS error??? [In reply to]

"Stan Cook" <scook[at]elp.rr.com> writes:

> I'm writing a script which at some point will map to a list of servers. The
> program will be keeping a log of problems it encounters to be reviewed
> later. To map the drive, I am using:
>
> sDrive =
> ["B","F","G","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X"
> ,"Y","Z"]
> iIndex = 0
> shellCmd = ""
> for s in sImage: # list of servers
> shellCmd = "map " + sDrive[iIndex] + ":=" + s
> iIndex=iIndex + 1
> os.system(shellCmd)

Would this help:
errorlevel = os.system(shellCmd)
if errorlevel != 0:
# do error stuff here


scook at elp

Jun 19, 2003, 8:04 PM

Post #3 of 4 (52 views)
Permalink
Capture DOS error??? [In reply to]

On 19 Jun 2003 12:29:35 +0200, Syver Enstad <syver[at]inout.no> wrote:

> "Stan Cook" <scook[at]elp.rr.com> writes:
>
>> I'm writing a script which at some point will map to a list of servers.
>> The
>> program will be keeping a log of problems it encounters to be reviewed
>> later. To map the drive, I am using:
>>
>> sDrive =
>> ["B","F","G","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X"
>>
>>
>> ,"Y","Z"]
>> iIndex = 0
>> shellCmd = ""
>> for s in sImage: # list of servers
>> shellCmd = "map " + sDrive[iIndex] + ":=" + s
>> iIndex=iIndex + 1
>> os.system(shellCmd)
>
> Would this help:
> errorlevel = os.system(shellCmd)
> if errorlevel != 0:
> # do error stuff here

Thanks! That was perfect. I originally was expecting the output to be a
string, but soon worked it all out.

Thanks again

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/


jkugler at bigfoot

Dec 6, 2007, 11:59 AM

Post #4 of 4 (52 views)
Permalink
Re: Capture DOS error??? [In reply to]

Tangen, Erik wrote:

> Did you ever get a solution to this?
> I am also in need of this solution.
> Thanks,
> Erik

Can you clarify? What is a DOS error? You mean an error in reading or
writing a file? That would be an IOError exception. If a file is not
found, or you can't read it, that's an OSError exception. Beyond that, I'm
not sure what you're asking for.

j

--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.