Help with creating a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with creating a script
# 1  
Old 04-09-2017
Help with creating a script

Hi everyone,
I am completely new to this forum and I have some questions regarding a script I am writing. I would be happy if anyone could help me with the small and precise script which should include if, then, else, while until, case and select.
The scenario is as follows:
1) A user starts the program typing the program name and first his/her first name and then the ID number as two parameters of the program.
2) The program welcomes the user somehow mentioning his/her ID number first, then his/her name and then displays the date and the time of the execution.
3) The program displays five codes and names of the five Football teams (one code and name per line) and asks the user to guess which the winner team is. The codes for Iceland, France, Portugal, Wales and Germany are respectively ICL, FRA, POR, WAL and GER respectively.);
4) After the user typed the country code, if the option is correct, the program informs about it and gives one two sentences explaining about some of the descriptions/ characteristics of the chosen team, otherwise the program warns about a mistake, and the user will guess until the correct option is chosen.
5) The program displays seven players of the Football team. The codes for seven players of Euro cup for Courtois, Silva, Messi, Nemar, Kane, Ronaldo, Bale is Co, Si, Me, Ne, Ka, Ro and Ba respectively.
6) Then the program invites to type three codes out of these seven (the codes may be typed in any sequence)
7) The user types these codes separating them by spaces;
8) The program displays a menu with these three codes and asks to choose one of them.
9) The user types the number of a chosen code in the list; the user will be able to type numbers until it is one of these three codes
10) The program displays the code with a comment on the same line and then, starting from the next line, displays a 3-4 lines description of that player. The description is taken from a file which name is the code of the country. If the file with that name is absent or not readable, the program informs the user about that and returns him/her to Step 5.
Note: These three files which names are codes of three countries out of the seven ones displayed in step 3 shall be prepared by the developer in advance and saved in the same directory as the script.
11) The program asks whether the eight previous steps described above, (3) to (10), should be repeated
12) If user says ‘yes', they are repeated; if the user says ‘no', the program terminates.
# 2  
Old 04-09-2017
Is that a homework question? Those should be posted in Homework & Coursework Questions filling in the correct form to its entirety according to the forum rules.

If this is not a homework assignment, please explain the company or project you work for and the nature of the problem you are working on.

In either case, please show us what you have tried so far to solve this problem on your own, using (CODE) tags where applicable.
# 3  
Old 04-09-2017
#!/bin/bash

echo -e "WELCOME $2 $1 $(date)"

value="yes"
while [ $value = "yes" -o $value = "y" ]
do
echo "Country Code"
echo "________ ________"
echo "ICELAND ICL"
echo "FRANCE FRA"
echo "PORTUGAL POR"
echo "WALES WAL"
echo "GERMANY GER"


echo -e "[*]SELECT SOME CODE AS METNIONED ABOVE: \c"
read code

while [ true ]
do
case "$code" in
ICL)
echo "YES THEY WON, THEY WON THE FINALS BY 2-1 AGAINST GERMANY"
break
;;
FRA)
echo "NO THEY LOST IN QUARTER FINALS WITH PORTUGAL"
break
;;
POR)
echo "THEY ALSO LOST"
break
;;
WAL)
echo "LOST"
break
;;
GER)
echo "LOST"
break
;;
*)
echo -e "!!INVALID CODE!!\n[*]PLZ SELECT SOME CORRECT CODE AS METNIONED ABOVE: \c"
read code
;;

esac
done



echo "Player Code"
echo "________ ________"
echo "Courtois Co"
echo "Silva Si"
echo "Messi Me"
echo "Nemar Ne"
echo "Kane Ka"
echo "Ronaldo Ro"
echo "Bale Ba"

#asking user to type three codes out of the seven player codes

echo -e "Enter any three codes (must be seperated by space) among the seven codes just displayed: \c"
read code1 code2 code3

echo -e "Your choices are (Enter a number ) \n 1>$code1 2>$code2 3>$code3: \c"
read choice # Reading the choice

while [ true ]
do
case "$choice" in
1)
echo $(cat $code1)
break
;;
2)
echo $(cat $code2)
break
;;
3)
echo $(cat $code3)
break
;;
*)
echo -e "Please enter the number from the list of choices: \c"
read choice
esac
done

echo -e "DO YOU WANT TO CONTINUE: \c"
read value

done



echo -e "*********************Now Exiting, Thank you for your time******************"





This is what I have done so far. I would like suggestion on using if statement, select and case whereas possible. Thank you all in advance.
# 4  
Old 04-09-2017
Did you read the entire note? Why didn't you answer the homework / courseork question? And, what about the code tags?
This User Gave Thanks to RudiC For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Creating script in rc.d

Hi, I have created customized scripts to start httpd and postgres (For CentOS 6) in /etc/init.d. However for it to work even after reboot, I have to put the script in /etc/rc.d/rc0.d, rc1.d, etc. # ls -lrt total 60 -rwxr-xr-x 1 root root 20199 Oct 4 2017 rc.sysinit -rwxr-xr-x 1... (6 Replies)
Discussion started by: anaigini45
6 Replies

2. Shell Programming and Scripting

Creating IN list in PLSQL script dynamically by using shell script

Hi all, I have a PLSQL script which has a IN list where it takes some ids as input. For example SELECT * FROM EMPLOYEE WHERE EMPLOYEE_ID IN (comma separated list ) I want to run this quest inside a shell script but I would like to prepare the IN list dynamically where the employee ids... (1 Reply)
Discussion started by: LoneRanger
1 Replies

3. Shell Programming and Scripting

Need help in creating file restoration script from a backup script.

Hi all i am struggling in creating a restore of env files while doing applications clone. the first file i created for copying the important configurations file which is running perfect now for reverting the changes i mean when i am restoring these files to its original places i have to do... (7 Replies)
Discussion started by: javeedkaleem
7 Replies

4. UNIX for Dummies Questions & Answers

Creating a script

Alright, well I did some more research since I originally posted this thread, and as much as I'd like to delete it, I can't, so I'll just extend my initial question a little. Right now I have 3 scripts: 1#!/bin/bash # script1 - Write all files modfied x days ago find .. -daystart -mtime 0... (2 Replies)
Discussion started by: Aussiemick
2 Replies

5. Programming

need help with creating a sh script

Hi everyone I’m not a programmer and my knowledge of scripting is very poor, now I’m stock in a task at work and would really appreciate it if someone could help me out. Here is the problem: 1. I have a file with 9 million entries that look like this : 611424167 610864581 611881523 609585386... (3 Replies)
Discussion started by: hiker1064
3 Replies

6. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies

7. Shell Programming and Scripting

(Urgent):Creating flat file using sql script and sqlplus from UNIX Shell Script

Hi, I need help urgently for following issue. Pls help me to resolve this issue. I am calling sql script file(file1.sql) from UNIX Shell Script(script1.ksh) using sql plus and trying to create flat file that contains all records returned from SQL query in SQL script(file1.sql) I given... (6 Replies)
Discussion started by: praka
6 Replies

8. Shell Programming and Scripting

Need help creating a script

I need to automate the following process: I have a list of ip address for printers in a file called iplist.txt, I need to take that list and run the command snmpget -v 1 -c public ip address sysName.0 for each ip address to see if the printer is running snmp, I want to the create a file... (4 Replies)
Discussion started by: inLine6
4 Replies

9. UNIX for Dummies Questions & Answers

creating a script

I am trying to create a application in OSX through UNIX that will run a script to mount an image from a CD-ROM and run the application which it corresponds to, all with double clicking on a icon in OSX. Any thoughts or ideas? -Mad (3 Replies)
Discussion started by: madknowledge
3 Replies

10. Programming

creating a new C script

All right. Heres the deal, I need to know everysingle command or funtion there is to create a new c file (file.c). Heres the catch: I cannot use text editors!!!:mad: I heard of a "gcc" command is that any good?:confused: Thanks..:cool: (2 Replies)
Discussion started by: AbRa-KaDabRa
2 Replies
Login or Register to Ask a Question