On Mar 12, 4:33 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Hitesh a écrit : > > > import string > > import os > > > f = open ("c:\\servername.txt", 'r') > > linelist = f.read() > > > lineLog = string.split(linelist, '\n') > > lineLog = lineLog [:-1] > > #print lineLog > > for l in lineLog: > > path1 = "\\\\" + l + "\\server*\\*\\xtRec*" > > glob.glob(path1) > > And ? What are you doing then with return value of glob.glob ? > > BTW, seems like an arbitrarily overcomplicated way to do: > > from glob import glob > source = open(r"c:\\servername.txt", 'r') > try: > for line in source: > if line.strip(): > found = glob(r"\\%s\server*\*\xtRec*" % line) > print "\n".join(found) > finally: > source.close() > > > When I run above from command line python, It prints the output of > > glob.glob > > but when I run it as a script, it does not print > > anything.... > > Not without an explicit print statement. This behaviour is useful in the > interactive python shell, but would be really annoying in normal use. > > > I know that there are files like xtRec* inside those > > folders.. and glob.glob does spits the path if run from python command > > line. > > > I tried something like this but did not work: > > for l in lineLog: > > path1 = "\\\\" + l + "\\server*\\*\\xtRec*" > > xtRec = glob.glob(path1) > > print xtRec > > > No results... > > With the same source file, on the same filesystem ? Unless your xtRec* > files have been deleted between both tests you should have something here. > > > xtRec = [] > > for l in lineLog: > > path1 = "\\\\" + l + "\\server*\\*\\xtRec*" > > xtrec = glob.glob(path1) > > You're rebinding xtRec each turn. This is probably not what you want.
Thank you for your reply. >From the return value I am trying to figure out whether the file xtRec* exist or not. I am newbie so exuse my ignorance... still learning. Somehow when I tried your solution, it takes 10mins to scan 200 plus servers but when I tried my code, it takes less then 2 mins. This is a puzzle for me, I gotta figure it out. hj -- http://mail.python.org/mailman/listinfo/python-list