Skip to content

Instantly share code, notes, and snippets.

@perenecabuto
Created September 9, 2016 20:56
Show Gist options
  • Save perenecabuto/7daf403dfdab1f13e2cc7a7fb12f8a35 to your computer and use it in GitHub Desktop.
Save perenecabuto/7daf403dfdab1f13e2cc7a7fb12f8a35 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# coding: utf-8
import sys
import subprocess
import random
def main(msg):
out, err = subprocess.Popen('cowsay -l', shell=True, stdout=subprocess.PIPE).communicate()
files = (" ".join(out.split("\n")[1:-1])).split(" ")
choice = random.choice(files)
subprocess.call("cowsay -f {} {}".format(choice, msg), shell=True)
if __name__ == "__main__":
message = " ".join(sys.argv[1:])
main(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment