Harshmage Posted December 8, 2009 Share Posted December 8, 2009 I've been trying to rewrite a script that was originally written in Python, and I'm nearly done. The only issue is the function to get the OU information from a web-database we have.Here's the original Python scripting for this function:expandcollapse popupurl = 'https://glacier.gccaz.edu/hwdb/name.plx?nic=' regexp = re.compile("^CN=([^$]*)[$],(.*)") regloc = re.compile("(GCC(Main|North))") def getMacAddr(): """ Gets all of the mac address from the computer and returns them as an array """ varMacList = [] if varOS == 'Windows-XP': for line in os.popen('ipconfig /all'): if line.lstrip().startswith('Physical Address'): varMac = line.split(':')[1].strip() if len(varMac) == 17: varMacList.append(varMac) else: for line in os.popen('/sbin/ifconfig'): if line.find('Ether') > -1: varMac = line.split()[4] varMacList.append(varMac) return varMacList def main(): """ Main Function """ macList = getMacAddr() for entry in macList: print 'Trying %s' % entry varDataArray = urllib.urlopen(url + entry).read().split() if varDataArray: print 'Found %s' % entry data = regexp.findall(varDataArray[0])[0] dloc = regloc.findall(varDataArray[0])[0] varName = data[0] varOU = data[1] varCampus = dloc[0] print "varName is %s" % varName print "varOU is %s" % varOU print "varCampus is %s" % varCampus setComputerName(varName) # commented out for testing setCampus(varCampus) # commented out for testing setOU(varOU) # commented out for testingThe output of the URL should reads like this:CN=A-056-O06$,OU=056,OU=A,OU=GCCMain,OU=Administrative,OU=DomainComputers,DC=gccaz,DC=eduThat's the full page. Source and all. There are no html markups.So I've got the GetMACFromIP function here, and that works fine! I did alter it to have a dash (-) instead of a colon ( for our URL checkup.My testing code goes like this:#include <GetMAC.au3> #include <INet.au3> $macAddr = _GetMACFromIP(@IPAddress1) $url = "https://glacier.gccaz.edu/hwdb/name.plx?nic=" $ou = _INetGetSource($url & $macAddr) MsgBox(0, "OU Info", $ou)However, this does not return the information at all. I even went to the point of replacing the URL with other websites, and they work just fine, so it's not that the INetGetSource function is bad. I've gone to great lengths to test and retest in various degrees. Link to comment Share on other sites More sharing options...
Harshmage Posted December 8, 2009 Author Share Posted December 8, 2009 Wait. Stop, nevermind. Seems that our DNS was resolving to a different server when used in a web browser. _INetGetSource was not. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now