Need help with basic unix script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need help with basic unix script
# 1  
Old 05-15-2007
Need help with basic unix script

What I am supposed to do is creat a menu with the following
Find a song
Find a album
Sort by artist
Delete a song
Add a new song
Quit
Now the file with the song information is database
Here is what I have so far
#!/bin/bash
#=================================================
#Script Name: menu
#By: Joe Teetzel
#Date: May 9th
# Purpose: A menu for Database
# Command Line: menu
#=================================================
trap "rm ./f 2> /dev/null; exit" 0 1 3
database=~/database
loop=y
while test $loop = "y"
do
clear
tput cup 10 52; echo "Songs Album and Artist Menu"
tput cup 11 52; echo "==========================="
tput cup 12 52; echo "S - Find a Song"
tput cup 13 52; echo "A - Find a Album"
tput cup 14 52; echo "I - Sort By Artist"
tput cup 15 52; echo "E - Add New Song"
tput cup 16 52; echo "D - Delete A Song"
tput cup 17 52; echo "O - View Full List"
tput cup 19 52; echo "Q- Quit"
tput cup 19 62;
read choice || continue
case $choice in
[Qq]) clear exit ;;
[Ii]) ./artistsort ;;
[Oo]) clear ; less $database ;;
[Ss]) songfind=~/database
clear
tput cup 5 1
echo "Enter song to search for: "
tput cup 5 35
read song
echo
grep $song $database | tr ':' ' '
echo
echo "Press ENTER to continue"
read continue
;;
[Aa]) ./album=~database
clear
tput cup 5 1
echo "Enter album to search for: "
tput cup 5 35
read album
echo
grep $album $database | tr ':' ' '
echo
echo "Press Enter to continue"
read continue
;;
[Ee]) songadd=~/database
looptest=y
while [ $looptest = y ]
do
clear
tput cup 1 52; echo "type in New Songs into here"
tput cup 2 52; echo "==========================="
tput cup 4 52; echo "Song Name : "
tput cup 5 52; echo "Artist Name : "
tput cup 6 52; echo "Album Name : "
tput cup 8 52; echo "Add another? (y)es or (q)uit: "
tput cup 4 66; read songname
if [ "$songname" = "q" ]
then
clear; exit
fi
tput cup 5 66; read arname
tput cup 6 66; read alname
if [ "$arname" > " "]
then
echo "$songname:$arname:$alname" >> $songadd
fi
tput cup 12 13: read looptest
if [ "looptest" = "q" ]
then
clear; exit
read $choice
[Dd])
clear
tput cup 16 52; echo "Delete Song"
tput cup 17 52 ; echo "Song: "
tput cup 17 59 ; read song
tput cup 18 52; echo "Accept? (y)es or (n)o: "
tput cup 18 75; read Accept
if test $Accept = "y"
then
sed /$song/d $database > f
cp f $database
rm f
fi
;;



*) tput cup 20 52; echo "Invalid Choice Please Choose Again"; read choice ;; esac
done


#CAN ANYONE TELL ME WHAT IS WRONG WITH IT AND WHY IT WILL NO WORK?
#THANK YOU IN ADVANCE
#btw I am running the bash shell

Last edited by stp0052; 05-15-2007 at 07:36 PM..
# 2  
Old 05-15-2007
by the way i am running fedora core redhat bash shell
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Need help with Basic Unix Program

I am a newbie to UNIX. I'm learning UNIX on my own, just trying to get the jerk of how things work in UNIX environment. I am familiar with Windows environment. Can anyone pls write simple 'envprint' programs to : 1) List all the environment Information (using the -l or --l options) 2) ... (1 Reply)
Discussion started by: agup17
1 Replies

2. Shell Programming and Scripting

Help required on basic Unix Bourne Shell Script

Howdy People :), I'm a newbie & its my first question here. I've started learning Unix Bourne Shell scripting recently and struggling already :p Can someone PLEASE help me with the following problem. Somehow my script is not working. Display an initial prompt of the form: Welcome to... (1 Reply)
Discussion started by: methopoth
1 Replies

3. UNIX for Dummies Questions & Answers

Basic Unix bash script help

Hello there Been using Unix bash scripting for two days now so am very new to this. I am currently doing a project now and i'm basically making a noughts and crosses game (or tic tac toe). I have created the board using an array. When I try and check to see if the array is empty using an If... (3 Replies)
Discussion started by: ChrisHoogie
3 Replies

4. Programming

Creating a basic UNIX shell script for chatting

Hey guys, This is quite simply what I'm trying to make: A program that runs in a UNIX terminal that you can output text messages to from another machine. These text messages would be prepended with a customized prompt. I'd also like to have the window spew out random dumps of flavor text not... (1 Reply)
Discussion started by: AcerAspirant
1 Replies

5. UNIX for Dummies Questions & Answers

some basic questions about unix ..

Hi all today i gone through worst interview of my life that for hour questions were so basic but i never though about them now i am figuring out answers my self but i would appreciate if you ppl help me ... i am listing some of the questions i remember .. 1 ) $ cat a.sh #! /usr/bin/ksh... (4 Replies)
Discussion started by: zedex
4 Replies

6. Solaris

basic unix question

Hello, I'm new to solaris and have an experience with linux. When we see network interface I can see qfe, hme, le0. What is that mean? Is it depend on the network card? (11 Replies)
Discussion started by: mokkan
11 Replies

7. UNIX for Dummies Questions & Answers

unix basic tutorials

Hi guys, am absolutely new to unix but i want to learn about this operating system. Can anybody help me on how to understand unix because i don't know anything about it. I will like it if i can get basic tutorials on this mostly software tutorials. (1 Reply)
Discussion started by: nayogod
1 Replies

8. UNIX for Dummies Questions & Answers

Unix basic help

What command would I use to list the first lines of all text files within my Unix directory or within any directory inside there? I was using "find" , "head" and "-exec" commands like this: find ~/Unix -name "*.txt" -exec head {} \; But its not perfectly working, please help me.... (2 Replies)
Discussion started by: carrera911
2 Replies

9. IP Networking

basic question about UNIX?

With not knowing absolute nothing about Unix can anyone let me in on how it is setup and how easy is it to learn?I'm using MML Commands and know that it is completely different but if I start learning commands in UNIX is that a good way to get started? (1 Reply)
Discussion started by: RoliOCon
1 Replies

10. UNIX for Dummies Questions & Answers

Basic unix

okay, im having some trouble. Go ahead, call me a retard, but i keep getting stuck. Suppose i want to open a Picture of Jesus(for the sake of simplicity) using unix. I type: open Desktop/Pictures/Jesus.jpg It opens, and its all well and good. But, suppose i want to open a picture called Joe... (4 Replies)
Discussion started by: HipCracka
4 Replies
Login or Register to Ask a Question