Help with creating a simple program!!


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with creating a simple program!!
# 1  
Old 09-22-2011
Help with creating a simple program!!

i am new to shell scripting!! i am making this program in bourne shell, that asks the user to input "Hello (their name)" or "question (their name)", any other input, "ERROR" will be outputted.
if they input "Hello (name)", i want to out saying Hello (name) but if they input "question (name)", i want to output "how are you (name)"!


anyone has any idea how to do this?

thanks
# 2  
Old 09-22-2011
here is a simple example;
Code:
#!/bin/bash
Y=jeff
Z=joe
echo "enter your Name "
read X
echo " your name is $X"
if [ $X = jeff ]
then 
echo " hello jeff "
exit -1
else 
	if [ $X = $Z ]
		then
		echo -e " you are not jeff" ; 
		echo " you are $Z "
		echo " we love $Z "
	fi
fi
echo " "
echo " "
echo "goodbye $X"
exit

# 3  
Old 09-22-2011
thanks for replaying doctorfoo1, but i want the user to enter the name! we dont know what the name is going to be, and they are meant to enter hello (name) or question (name) and the outputs are going to be different!!!

plzz help!!

thanks
# 4  
Old 09-22-2011
doctorfoo1 was very clear in his post: He gave you an example, you dont expect other to do all the work for you...
You are left now with a sample script for you to adapt to fit your needs, we hope your next post will be your adaptation (using code tags Smilie ...) asking e.g. Is it possible to use a loop...
Before replying promptly as you did, I suggest you copy the given code and run it, you may would have asked then something else... (You did not run the code, did you?)
# 5  
Old 09-22-2011
yes play with the other one. but here is a different approach

Code:
#!/bin/sh
echo What is your name?
read MY_NAME
echo "Hello $MY_NAME - hope you're well."

;
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Help with creating a simple shell script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a shell script that accepts two arguments. The two arguments are the name of 2 files. • If the arguments... (3 Replies)
Discussion started by: Scripter12345
3 Replies

2. UNIX for Beginners Questions & Answers

Creating a simple ID Script

Hello everybody, :wall:I am new to Linux and I want to create a simple script on Ubuntu that will allow to make database with a few perimeters. create file and name it Database and complete it with any information id firstname lastname phone 0 1 2 3 4 ... (4 Replies)
Discussion started by: kkishore4580
4 Replies

3. Shell Programming and Scripting

Help with simple program. (beginner)

Hey all, Writing a program that searches for a username and if they are online creates a 'beep' and sends the username and date to a log file. the error i am getting is: paul.obrien16@aisling:~/os$ bash checklogin : command not found Enter username paul.obrien16 ': not a valid... (2 Replies)
Discussion started by: sexyladywall
2 Replies

4. Programming

Creating a simple Help Desk system in PHP

hi guys i'm new to php,,i'm asked to develop a simple online help desk (where the admin can view the problem an forward it to another one to handle it and so on) or get a ready sytem then modify alil on it but i dont know where to start ir to find any suggestion please? (2 Replies)
Discussion started by: kedah160
2 Replies

5. Programming

Xlib simple program.

I don't know if it is right to ask you this. Can someone help me write a simple Xlib program,with button on it,and all that button do is switch 2 messages. I have tried and tried,but never get past Hello World. Can someone help me please? ---------- Post updated at 10:17 PM ---------- Previous... (2 Replies)
Discussion started by: megane16v
2 Replies

6. Shell Programming and Scripting

Creating simple shell program

Hi, I'm new to UNIX shell programming... can anyone help in doing the following : 1) create a text file named "Model File" having following columns : Name Number Physics Chemistry 2) prompt user to n rows enter the name, number, physics ,chemistry 3) display the entire columns and rows... (1 Reply)
Discussion started by: Mayuri P R
1 Replies

7. Shell Programming and Scripting

creating a simple archiving script

Im trying to create a script to archive specified directories into a specified tarball backup file. This is what i want the input to look like ex. save -i '/bin/b*' -i '/bin/ls' -o backup this is what i have #!/bin/bash #save - backup file script unset myInput unset myOutput while... (3 Replies)
Discussion started by: lensmen
3 Replies

8. Programming

a simple chat program

any suggestions on how i could create a simple chat program between two terminals using pipes? thanks (1 Reply)
Discussion started by: kelogs1347
1 Replies

9. Shell Programming and Scripting

Creating instances of a program

Hi, Presently I have script #!/bin/ksh in which 4 executables are executed as 1,2,3 and 4.Executable 2 is an extract program which extracts records from a table.and executable 4 is a program that updates a database. Currenlty this process takes a hell lot of time and my aim is to reduce the... (2 Replies)
Discussion started by: tushar_johri
2 Replies
Login or Register to Ask a Question