Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Linux and Unix
Tag Cloud
access acer asus bios bsod computer crash desktop dns driver drivers error ethernet excel freeze gaming graphics hard drive hardware hdmi internet laptop malware memory monitor motherboard network printer problem ram registry repair router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
Solved: Question

Reply  
Thread Tools
robby_20's Avatar
Computer Specs
Member with 56 posts.
 
Join Date: Apr 2006
Experience: Intermediate
02-Jul-2006, 03:35 PM #1
Solved: Question
I just can't figure out how to do this. Anyone know how to create a shell script in vi unix

use vi or emacs or any other editor or your choice and create a script file called car.sh
your script should ask the user to enter the name of a country from the following list:
America, France, Germany, Italy, Japan and Korea

The script then uses an appropriate control structure ( if or switch) to display the name of a car made in the selected country. Use the following list of cars for reference:



Country
Car

America
Ford

France
Peugeot

Germany
Porshe

Italy
Ferrari

Japan
Lexus

Korea
Sonata
linuxphile's Avatar
Administrator with 429 posts.
 
Join Date: Mar 2003
Location: MD
Experience: Intermediate
02-Jul-2006, 03:57 PM #2
I'd be delighted to help you in your journey to learn shell scripts, however, this looks like it might be a class assignment. I recommend you do the necessary reading to learn how to write shell scripts.

All the information you require for writing a script with the above specifications can be found here: http://pegasus.rutgers.edu/~elflord/unix/bash-tute.html
__________________
http://about.me/dmccarthy
robby_20's Avatar
Computer Specs
Member with 56 posts.
 
Join Date: Apr 2006
Experience: Intermediate
02-Jul-2006, 04:59 PM #3
just a tip, please.
Here is my first attempt. you are right this is part of a class assignment. I have read the chapter a million times and looked at online documentation. If you could provide a couple tips that would be great. But if not, no worries. I'll just keep trying.


#! /bin/csh:
x=please Select one of the following countries:America, France, Germany, Italy,Korea, Japan



if condition $America = $Ford
then
echo a = b
fi

if condition $France = $Peugot
then
echo a = b
fi

if condition $Germany = $Porsche
then
echo a = b
fi

if condition $Italy = $Ferrari
then
echo a = b
fi


if condition $Japan = $Lexus
then
echo a = b
fi

if condition $Korea = $Sonata
then
echo a = b
o a = b
fi

if condition $Germany = $Porsche
then
echo a = b
fi

if condition $Italy = $Ferrari
then
echo a = b
fi


if condition $Japan = $Lexus
then
echo a = b
fi

if condition $Korea = $Sonata
then
echo a = b
fi
linuxphile's Avatar
Administrator with 429 posts.
 
Join Date: Mar 2003
Location: MD
Experience: Intermediate
02-Jul-2006, 05:19 PM #4
One of the things in shell scripts that caught me early on was string evaluations. You cannot use operators such as = < > !- <>.

For example if you want to see if two strings are the same use the following:

if [ $string -eq $string2 ]; then
;do stuff
fi

The spaces between the brackets and the variables are important. Your script will not run otherwise.

If you want to interactively read user input you'll need to use a combination of the "echo" and "read" commands.

HTH
__________________
http://about.me/dmccarthy

Last edited by linuxphile; 02-Jul-2006 at 05:24 PM..
robby_20's Avatar
Computer Specs
Member with 56 posts.
 
Join Date: Apr 2006
Experience: Intermediate
02-Jul-2006, 05:32 PM #5
thanks
Thanks for the tip, I have tried a few variations. But no dice. I am going to try and mess around with several things and try to get something to work.
klam's Avatar
Senior Member with 181 posts.
 
Join Date: Apr 2006
Experience: Advanced
02-Jul-2006, 06:11 PM #6
Hey Robbie just so you know, Multiple Posting is not allowed in the forum:

http://www.techguy.org/rules.html

You posted this into the programming section as well...
robby_20's Avatar
Computer Specs
Member with 56 posts.
 
Join Date: Apr 2006
Experience: Intermediate
02-Jul-2006, 08:02 PM #7
closing thread
I thought I had removed that posting. but sorry about that. Anyways I figured out my mistakes and am closing this thread as solved.


Thanks to all that helped
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
02-Jul-2006, 10:48 PM #8
Read a Value in and use a case statement.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 07:45 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.