#This is a pretty weird script, it gets lines of text from somewhere #And it makes a playlist, to keep the amount of tracks loosely connected #To the amount of text. import sys from subprocess import Popen, PIPE magic = sys.stdin.readlines() lines = [] for line in magic: lines.append(line) pfind = Popen(["find", "/media/mp3" ], stdout=PIPE) pgrep = Popen(["grep", "mp3"], stdin=pfind.stdout, stdout=PIPE) pfind.stdout.close() # Allow pfind to receive a SIGPIPE if pgrep exits. pshuf = Popen(["shuf", "-n {0}".format(len(lines))], stdin=pgrep.stdout) pgrep.stdout.close()