I feel sure one of these existed...
I guess it's a program that ignores whatever your input is and gives you back one of maybe 4/8/16 (?) answers seemingly at random every time it gets any command at all.
Did I dream it?
I feel sure one of these existed...
I guess it's a program that ignores whatever your input is and gives you back one of maybe 4/8/16 (?) answers seemingly at random every time it gets any command at all.
Did I dream it?
__________________
Ran a quick search myself, most of the top results are for GUI versions, and in particular the magic 8 ball screenlet. Either way if it's just a simple program that displays one of so many random messages with no regard to the actual input (and assuming it has no extra options to pass to it when executed) then it should be fairly easy to write in bash or python.
If I remember tomorrow I might quickly throw something together along those lines, probably using python.
Edit: Nevermind, quickly wrote up something in two minutes, hope this is sort of what you want? (Requires python 2.6)
Last edited by HoKaze; November 14th, 2010 at 11:04 PM.
Hmmm, I bored. So here is a bash/fortune variant. You need to install fortune first, then create the fortune file, /usr/share/games/fortunes/magic8ball:
create the random access file:Code:As I see it, yes % It is certain % It is decidedly so % Most likely % Outlook good % Signs point to yes % Without a doubt % Yes % Yes - definitely % You may rely on it % Reply hazy, try again % Ask again later % Better not tell you now % Cannot predict now % Concentrate and ask again % Don't count on it % My reply is no % My sources say no % Outlook not so good % Very doubtful %
and run:Code:sudo strfile /usr/share/games/fortunes/magic8ball
Code:read -p "What's your question?"$'\n' && fortune magic8ball
Nice simple script to have some command line fun. One problem: The terminal crashes if I launch the script from a custom launcher after I type the question and hit enter. Though the script works fine if I do ./magic8ball from terminal.
I'm pretty sure most launchers will run a program in the terminal and then close the terminal as soon as the program finishes. In other words, it'll print the response but close the terminal before you can actually even see the response. The way to avoid this is to either run it manually from the command line, add a pause onto the end of the script or request additional user input to close the script after the message has been displayed.
(This applies to both the python script and the fortune method)
Fix for python version:
Add this code to the end of the file if you want to have to press enter to continue
or add this to pause for 2 seconds:Code:raw_input()
Fix for bash/fortune method:Code:import time time.sleep(2)
Instead of using this command,
Use this command instead:Code:read -p "What's your question?"$'\n' && fortune magic8ball
Code:read -p "What's your question?"$'\n' && fortune magic8ball && sleep 2
One more question. Is it possible to loop entire thing after raw_input()? I mean after I hit enter I am again brought to the line 'what is your question' The only way to close terminal would be from window controls. Sorry I am no programmer and i have no idea how to do this
Code:while (True): raw_input("What is your question?\n") print random.choice(answers) + '\n'Code:while true; do read -p "What's your question?"$'\n' && fortune magic8ball; echo; done
I have combined everything form your scripts and added standard answers from wikipedia
Code:#!/usr/bin/env python # Magic 8 ball program import random answers = ["As I see it, yes","It is certain","It is decidedly so","Most likely","Outlook good","Signs point to yes","Without a doubt","Yes","Yes definitely","You may rely on it","Reply hazy, try again","Ask again later","Better not tell you now","Cannot predict now","Concentrate and ask again","Don't count on it","My reply is no","My sources say no","Outlook not so good","Very doubtful"] raw_input("What is your question?\n") response = random.choice(answers) print response + '\n' while (True): raw_input("What is your question?\n") print random.choice(answers) + '\n'
Bookmarks