import random
import sys
+print_to_stderr = False
+if (len(sys.argv) == 1):
+ pass
+elif (len(sys.argv) == 2) and (sys.argv[1] == "-S"):
+ print_to_stderr = True
+else:
+ print >>sys.stderr, "invalid command-line arguments"
+ sys.exit(1)
+
allfiles = []
-for root, dirs, files in os.walk(".", followlinks=True):
+for root, dirs, files in os.walk("."):
for f in files:
allfiles.append(os.path.join(root, f))
if (len(allfiles) == 0):
random.seed(None)
r = random.randint(0,len(allfiles) - 1)
print(allfiles[r])
+if (print_to_stderr):
+ print >>sys.stderr, (allfiles[r])
sys.exit(0)