Sponsored Content
Full Discussion: magic 8ball
Top Forums UNIX for Dummies Questions & Answers magic 8ball Post 302308896 by JamieMurry on Monday 20th of April 2009 01:59:39 PM
Old 04-20-2009
magic 8ball

when i use this code for the script of the magic 8ball, i get an error message and it always displays the sam answer. What am i doing wrong or what am i missing thanks

#!/bin/sh
#< Magic eight ball!
# KW 26/11/04
# Requires "rand"

echo "Enter \"q\" followed by return to quit"

function ask_it
{
echo -e "\nAsk the mysterious 8-ball a question..."
read question
}

ask_it

while [ "$question" != "q" ]; do
rand=`rand 100`
if [ "$rand" -lt "10" ]; then
echo "It is definite"
elif [ "$rand" -lt "20" ]; then
echo "It is looking probable"
elif [ "$rand" -lt "30" ]; then
echo "There is great certainty"
elif [ "$rand" -lt "40" ]; then
echo "Maybe"
elif [ "$rand" -lt "50" ]; then
echo "It doesn't look promising"
elif [ "$rand" -lt "60" ]; then
echo "Probably not"
elif [ "$rand" -lt "70" ]; then
echo "A definite no"
elif [ "$rand" -lt "80" ]; then
echo "All the signs point to yes"
elif [ "$rand" -lt "90" ]; then
echo "All the signs point to no"
else
echo "Who can be sure? I'm not..."
fi
ask_it
done

exit 0
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Boot Magic 7

For a multi-boot setup (win2K, XP & SuSE) over 3 drives, where should Boot Magic be installed to? And does it matter which o/s installs it? (3 Replies)
Discussion started by: onestepto
3 Replies

2. UNIX for Advanced & Expert Users

what is magic file ?

i am working under this sysytem SunOS sparc SUNW,UltraAX-i2 Some system on this server creates a file named like this. Elem_ee.xml.gz Elem_ee.xml.gz.magic In order to look into Elem_ee.xml.gz.magic, i first renamed Elem_ee.xml.gz.magic to Elem_ee.xml.gz and tried to unzip it. but returns... (3 Replies)
Discussion started by: oppai
3 Replies

3. Filesystems, Disks and Memory

Bad Magic Number

Dear All, i have a SCSI hard disk drive i'm installing on it solaris 5 and the workstation is sun sparc, i made an image of this H.D using Norton Ghost 6, so i took off the SCSI H.D from the sun workstation and put it on a Compaq server then i booted the server from the Norton Ghost floppy disk... (0 Replies)
Discussion started by: wesweshahaha
0 Replies

4. UNIX for Dummies Questions & Answers

magic.h

Where can I find #defines for filetypes like the ELF etc and the magic.h file? CAn anyone advice. Thanks in advance. (0 Replies)
Discussion started by: vijlak
0 Replies

5. UNIX for Advanced & Expert Users

magic.h

Where can I find #defines for filetypes like the ELF etc and the magic.h file? CAn anyone advice. Thanks in advance. (1 Reply)
Discussion started by: vijlak
1 Replies

6. Shell Programming and Scripting

sed magic!

Hi, I have this line in my script, and works perfect! tran= "$(sed = "$fname" | sed "/./N; s/\n/: /" | sed -n "${beg},${end}p")" $fname its a file, and gets multilines between beg and end.: Something like this: 1: line a 2: line b 3: line c But now, I want insert in the end of each... (9 Replies)
Discussion started by: vibra
9 Replies

7. Shell Programming and Scripting

sed magic

I want to become an expert @ using sed, but i do not have enough time... Atm I have a repository in my apt/sources.list but it is commented out since i do not want to install packages from it (backtrack repository) except the exploitdb package. I would like make a command, lets say... (5 Replies)
Discussion started by: redsolja
5 Replies

8. What is on Your Mind?

I got a magic wand

My new magic wand just came. It looks great. Looking at it, it looks like it is carved by hand from a solid piece of wood. It could easily serve as a prop in a Harry Potter film. But it is actually a high tech appliance. A built-in accelerometer can detect how you are moving the wand. ... (2 Replies)
Discussion started by: Perderabo
2 Replies

9. Shell Programming and Scripting

sed magic

Hello all, I have an inherited an old ugly script I'm trying to clean up a bit. What I am currently working on is a line like the following: Complication=" and ta.secID = 011222 and upper(ta.proc_ctrl_no) != 'IMPACT'";; I just want to combine a search for lines that begin with... (5 Replies)
Discussion started by: blip42
5 Replies
File::MimeInfo::Magic(3pm)				User Contributed Perl Documentation				File::MimeInfo::Magic(3pm)

NAME
File::MimeInfo::Magic - Determine file type with magic SYNOPSIS
use File::MimeInfo::Magic; my $mime_type = mimetype($file); DESCRIPTION
This module inherits from File::MimeInfo, it is transparent to its functions but adds support for the freedesktop magic file. Magic data is hashed when you need it for the first time. If you want to force hashing earlier use the "rehash()" function. EXPORT
The method "mimetype" is exported by default. The methods "magic", "inodetype", "globs" and "describe" can be exported on demand. METHODS
See also File::MimeInfo for methods that are inherited. "mimetype($file)" Returns a mime-type string for $file, returns undef on failure. This method bundles "inodetype()", "globs()" and "magic()". Magic rules with an priority of 80 and higher are checked before "globs()" is called, all other magic rules afterwards. If this doesn't work the file is read and the mime-type defaults to 'text/plain' or to 'application/octet-stream' when the first ten chars of the file match ascii control chars (white spaces excluded). If the file doesn't exist or isn't readable "undef" is returned. If $file is an object reference only "magic" and the default method are used. See below for details. "magic($file)" Returns a mime-type string for $file based on the magic rules, returns undef on failure. $file can be an object reference, in that case it is supposed to have a "seek()" and a "read()" method. This allows you for example to determine the mimetype of data in memory by using IO::Scalar. Be aware that when using a filehandle or an "IO::" object you need to set the ":utf8" binmode yourself if apropriate. "rehash()" Rehash the data files. Glob and magic information is preparsed when this method is called. If you want to by-pass the XDG basedir system you can specify your database directories by setting @File::MimeInfo::DIRS. But normally it is better to change the XDG basedir environment variables. "default" "describe" "extensions" "globs" "inodetype" These routines are imported from File::MimeInfo. SEE ALSO
File::MimeInfo LIMITATIONS
Only word sizes of 1, 2 or 4 are supported. Any other word size is ignored and will cause a warning. BUGS
Please mail the author when you encounter any bugs. AUTHOR
Jaap Karssenberg <pardus@cpan.org> Copyright (c) 2003, 2012 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-05 File::MimeInfo::Magic(3pm)
All times are GMT -4. The time now is 02:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy