How to add a status once a step is complete on the header part of a menu?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to add a status once a step is complete on the header part of a menu?
# 1  
Old 04-25-2014
How to add a status once a step is complete on the header part of a menu?

Hi Guru's,

i am creating a script that will update menu of either complete or failed.

Code:
#!/bin/bash
choice=0

while [ $choice -ne 4 ]
do

echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""
echo "                ###############################################"
echo "                # Choose a script to run from the list below: #"
echo "                #                                             #"
echo "                # 1) List files   ${status}                #"
echo "                # 2) Copy  ${status}                #"
echo "                # 3) run script  ${status}                #"
echo "                #                                             #"
echo "                # 4) QUIT                                     #"
echo "                #                                             #"
echo "                ###############################################"

echo ""
read -p "                Choice: " choice

case "$choice" in
 1 ) ls -ltr
     RET=$?
     status=""

     if [ $RET -gt 0 ]
     then
        status = "COMPLETE"
     else
        status = "FAILED"
     fi
   ;;
 2 ) cp -pv <file> <dest> ;;
 3 ) ./runprog.sh ;;
 4 ) clear; exit 1 ;;
 *) exit;;
esac

clear

done

the output i am looking is that when return value is ZERO, it will display status COMPLETE on the MENU part else FAILED

EXPECTED OUTPUT

Code:
###############################################
# Choose a script to run from the list below:                                 #
#                                                                                          #
# 1) Rename script   COMPLETE                                                  #
# 2) Another script  COMPLETE                                                  #
# 3) OneMore script  FAILED                                                      #
#                                                                                          #
# 4) QUIT                                                                              #
#                                                                                          #
###############################################

is this possible?

Cheers,
ME

Last edited by Don Cragun; 04-25-2014 at 05:08 AM.. Reason: Add CODE tags for output.
# 2  
Old 04-25-2014
Code:
     if [ $RET -gt 0 ]      then         status = "COMPLETE"      else         status = "FAILED"      fi

Remove the spaces while you are assigning.
The command will return 0 if its has completed successfully and >0 if it failed.So you need to change your test.

Use separate variables to store the status for different options. This will show the same status for all the options.

And what should be the value when its being run for the first time?
Better initialize status with some value.
# 3  
Old 04-25-2014
but the problem is the status value is not reflecting on the Menu side where i want it to be
# 4  
Old 04-25-2014
Quote:
Originally Posted by reignangel2003
but the problem is the status value is not reflecting on the Menu side where i want it to be

Run the script with suggested changes and post back the result. I cannot help you unless I know what errors you are getting. Also post the the updated script(with the suggested changes).
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. What is on Your Mind?

Slowly Removing Bold Font Style - Step-by-Step

FYI, I'm slowly removing a lot of the bold font-styles from titles of discussions, forum titles, etc I'm not removing bold for the entire site because we do need bold from time to time, especially in posts and sometimes in other places. However, the original forum style had way too much... (3 Replies)
Discussion started by: Neo
3 Replies

2. UNIX for Beginners Questions & Answers

Automation script for email alert when a job get complete with status successful.

Guyz, Please let me know about script which is to be sending an automatic email to particular mail id's when a monotoring job get complete with status successful. (1 Reply)
Discussion started by: Rehan Ahmad
1 Replies

3. Red Hat

Bash: menu-complete and reverse

Hi, In the archives I found this: And this works fine. $if mode=vi "\C-0-": digit-argument TAB: menu-complete "\e But what I want is to reverse this. So I want that tab does reverse menu completion and shift tab does normal menu completion. Can anyone help me with this? Thanks (0 Replies)
Discussion started by: ozkanb
0 Replies

4. Shell Programming and Scripting

Add column header and row header

Hi, I have an input like this 1 2 3 4 2 3 4 5 4 5 6 7 I would like to count the no. of columns and print a header with a prefix "Col". I would also like to count the no. of rows and print as first column with each line number with a prefix "Row" So, my output would be ... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

5. Linux

May you explain step by step where and how I will add pseudo code

Thank all of you. May you explain step by step where and how I will add pseudo code Note : I have Linux 2.6.24-26-server on x86_64 dears kindly help me (3 Replies)
Discussion started by: nonowa
3 Replies

6. UNIX for Dummies Questions & Answers

BASH complete-filename & menu-complete together

Hi, Does anyone know how to make BASH provide a list of possible completions on the first tab, and then start cycling through the possibilites on the next tab? Right now this is what I have in my .bashrc: bind "set show-all-if-ambiguous on" bind \\C-o:menu-complete This allows... (0 Replies)
Discussion started by: Mithu
0 Replies

7. Shell Programming and Scripting

comparing part of header with part of detailed records.

Hi there, I am lil confused with the following issue. I have a File, which has the following header: IMSHRATE_043008_101016 a sample detailed record is :9820101 A982005000CAVG030108000000000000010169000MAR 2008 9820102 MAR 2008 D030108 ... (1 Reply)
Discussion started by: cmaroju
1 Replies

8. Shell Programming and Scripting

works step by step on command line but not in script

Hi all, The following script is fine when I work via command line m=1 c=0 while do echo $m gnokii --getsms IN $m > out.txt; m=`expr $m + 1`; cat out.txt >> message_log; ############ read first crap< <(sed -n '/Text:/{n;p;}' out.txt); read message< <(sed -n '/Text:/{n;p;}'... (2 Replies)
Discussion started by: whamchaxed
2 Replies
Login or Register to Ask a Question