Script help, please!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script help, please!
# 1  
Old 11-14-2007
Script help, please!

I am writing a script that will display my name and date, then a menu with 5 selections. Each selection should print its respective command to the screen. However, when I run the script and make a selection, I only see the output for a brief second...say for example, I select "1" which should display a directory listing...I see it but only for a second. What is wrong?

Here is my script:

# !/bin/bash
#==========================================================
# Script Name: Lab9
# By: M.O.B.
# Date: 11/14/2007
# Purpose: A menu to run various commands
# Command Line: Lab9
#==========================================================
c=0
while [ $c -ne 5 ]
do
clear
echo "My name is: $name"
echo "The Date is: `date '+%x'` "
echo "=============================="
echo "1 - List Directory"
echo "2 - Display who is online"
echo "3 - Print Calendar"
echo "4 - Show all my processes"
echo "5 - Quit"
echo "Enter your choice: "
tput cup 8 19;
read c
case $c in
1)
ls -l
;;
2)
who -T
;;
3)
cal
;;
4)
ps --user ME
;;
5)
read c
echo "Goodbye"
;;
*)
echo "Error in choice, try again"
;;
esac
done

Any ideas?

Thanks,

Trellot
# 2  
Old 11-14-2007
1. Don't post homework, see rule 6.

2. You might want to ask yourself "I wonder what does 'clear' does?"
# 3  
Old 11-14-2007
Make pause in each option of Case Statement

Make pause by applying "sleep" or "read a" statement in every case (case1, case 2, case 3 ...) options in Case Statement.

e.g.
...
...
case $c in
1)
ls -l
read a
;;
...
...
# 4  
Old 11-15-2007
Quote:
Originally Posted by porter
1. Don't post homework, see rule 6.

2. You might want to ask yourself "I wonder what does 'clear' does?"
Yowsers! Ok..ok..if that's the rule, fine. However, this is an online course I'm taking and the professor has already encouraged to use the net for assistance. It wasn't as if I was asking you to write the whole script that I posted. I only had one question concerning it.

At any rate, I will find another forum in the future.

Trellot
# 5  
Old 11-15-2007
Quote:
Originally Posted by bobbygsk
Make pause by applying "sleep" or "read a" statement in every case (case1, case 2, case 3 ...) options in Case Statement.

e.g.
...
...
case $c in
1)
ls -l
read a
;;
...
...
Thank you, Bobbygsk, I will try this.

Much appreciated,

Trellot
# 6  
Old 11-16-2007
Quote:
Originally Posted by Trellot
Thank you, Bobbygsk, I will try this.

Much appreciated,

Trellot
And your suggestion worked great, thanks for your input.

Trellot
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

5. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies
Login or Register to Ask a Question