#!/usr/bin/python
#this is a simple umounter for WNM called... WNUM... just run it win no args to 
#umount all the shares. Use the argument "umount" as root to get rid of troublesome
#shares.

import string, os, commands, getopt, sys

tmp,args = getopt.getopt(sys.argv[1:], '')

umountcommand = 'smbumount "'
if args:
    if 'umount' in args:
	umountcommand = 'umount "'

status, output = commands.getstatusoutput('mount')
if status:
    print 'Error with mount'

mountoutput = string.split(output, '\n')
    
for x in mountoutput:
    if x[0:2] == '//':
	start = string.find(x, 'on /')
	stop  = string.find(x, 'type')
	path  = string.strip(x[start+3:stop-1])
	
	command = umountcommand + path + '"'
	os.system(command)
	print command
	command = 'rmdir "' + path + '"'
	os.system(command)
	
