OK, I had a bit of free time and I've been meaning to play with Python for a bit.
I'm deciding to use XKCD's famous joke about sudo to write a Python script that uses raw input and loops etc.
You'll need to have espeak installed, but if you run Ubuntu (or any other major Linux distribution) that should be pretty easy.
To install in Ubuntu:
sudo apt-get install espeak*
Here is my first draft:
#!/usr/bin/python
import os
sudo_command = "sudo make me a sandwich"
request = (raw_input('What do you want? '))
if request == "sudo make me a sandwich":
print "OK"
os.system("espeak OK")
elif request == "make me a sandwich":
print "Make it yourself"
os.system("espeak 'Make it yourself'")
else:
print "Mate, bugger off"
os.system("espeak 'Mate, bugger off'")
I'm deciding to use XKCD's famous joke about sudo to write a Python script that uses raw input and loops etc.
You'll need to have espeak installed, but if you run Ubuntu (or any other major Linux distribution) that should be pretty easy.
To install in Ubuntu:
sudo apt-get install espeak*
Here is my first draft:
#!/usr/bin/python
import os
sudo_command = "sudo make me a sandwich"
request = (raw_input('What do you want? '))
if request == "sudo make me a sandwich":
print "OK"
os.system("espeak OK")
elif request == "make me a sandwich":
print "Make it yourself"
os.system("espeak 'Make it yourself'")
else:
print "Mate, bugger off"
os.system("espeak 'Mate, bugger off'")
No comments:
Post a Comment