Problems with Echo command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problems with Echo command
# 1  
Old 03-25-2009
Problems with Echo command

Hi there im having a problem with an echo command and have been trying to fix it for a little while now but just cant seem to see the issue. The code is as follows:

Code:
#!/bin/bash
#Filename: Assignment Author: Luke Francis
echo "OPERATOR ADMINISTRATIVE TOOL"
echo "Please enter your password:"
read password
  if [ $password -eq 0600519 ]
          then
          clear
              echo "1. User Information"
               echo "2. Network Connectivity"
                echo "3. Processes"
                 echo "4. System Information"
                  echo "5. Hardware Utilization"
                   echo "Which option do you require?"
read menunumber
  if [ $menunumber -eq 1 ]
               then
                   clear
                           echo "USER INFORMATION"
                            echo "1. Registered Users"
                             echo "2. Disk Usage"
                              echo "3. Last Logins"
                              echo "Which option do you require?"
read menunumber2
  if [ $menunumber2 -eq 1 ]
               then
                     awk -F:  '{print $1}' /etc/passwd
  elif [ $menunumber2 -eq 2 ]
               then
                      du
  elif [ $menunumber2 -eq 3 ]
               then
                      who
        else
            echo "INCORRECT PASSWORD"
               fi
                    fi
                        fi
                            echo "Thank you for using the Operator Administrative Tool."
read menunumber
  if [ $menunumber -eq 2 ]
              then
                  clear
                        echo "



The problem im having is it seems as though when the program is run and an incorrect password entered, the echo command warning the user of incorrect password is skipped so instead of it saying INCORRECT PASSWORD with Thank you for using the Operator Administrative Tool underneath it only displays the thank you line. If someone could please point out where im going wrong i'd be most grateful because its had me puzzled for a while im relatively new to this. thanks.

Last edited by vidyadhar85; 03-25-2009 at 03:31 PM.. Reason: code tags added
# 2  
Old 03-25-2009
try placing your else block after ending 2 if blocks
Code:
#!/bin/bash
#Filename: Assignment Author: Luke Francis
echo "OPERATOR ADMINISTRATIVE TOOL"
echo "Please enter your password:"
read password
if [ $password -eq 0600519 ]
then
clear
echo "1. User Information"
echo "2. Network Connectivity"
echo "3. Processes"
echo "4. System Information"
echo "5. Hardware Utilization"
echo "Which option do you require?"
read menunumber
if [ $menunumber -eq 1 ]
then
clear
echo "USER INFORMATION"
echo "1. Registered Users"
echo "2. Disk Usage"
echo "3. Last Logins"
echo "Which option do you require?"
read menunumber2
if [ $menunumber2 -eq 1 ]
then
awk -F: '{print $1}' /etc/passwd
elif [ $menunumber2 -eq 2 ]
then
du
elif [ $menunumber2 -eq 3 ]
then
who
fi
fi
else
echo "INCORRECT PASSWORD"fi
echo "Thank you for using the Operator Administrative Tool."
read menunumber
if [ $menunumber -eq 2 ]
then
clear
echo "

# 3  
Old 03-25-2009
Thanks for the help vidyadhar85, i should have included this earlier i have tried this but but get faced with the following:

OPERATOR ADMINISTRATIVE TOOL
Please enter your password:
232
INCORRECT PASSWORD
Thank you for using the Operator Administrative Tool.

./Assignment: line 44: unexpected EOF while looking for matching `"'
./Assignment: line 45: syntax error: unexpected end of file

That is how i want the output to be though, minus the two syntax error lines lol, any ideas on how i can ammend that
# 4  
Old 03-25-2009
one extra backquote is there and last if statement doesn't have fi so check yourself you will find it
# 5  
Old 03-25-2009
Thanks alot it works fine now Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

About echo command in csh

hi linux expert I want to print the following lines ( or similar) with the echo command in csh script. how to do it when the number of lines is high and the use of the \ symbol for each line is difficult? Thanks in advance samad 000 'iexpt ' = experiment number x10 (000=from... (4 Replies)
Discussion started by: abdossamad2003
4 Replies

2. Shell Programming and Scripting

Need to echo command successful if command is executed successfully

Hello, I have written a command n shell script : srvctl relocate service -d t1 -s s1 -i i1 -t t1 -f If the above command executes successfully without error I need to echo "Service relocated successfully and If it errors out I need to trap the errors in a file and also need to make... (1 Reply)
Discussion started by: Vishal_dba
1 Replies

3. UNIX for Dummies Questions & Answers

Help me with Echo Command

Hi All I have the big statement which needs to be appended to the file MANUALLY without opening the file. So, i tried with echo command echo " failure ( 4446): for host xx.xx.xx.xxx trying to GET /index.html, wl-proxy reports: exception occurred for backend host 'xx.xx.xxx.xx/12210/12210':... (11 Replies)
Discussion started by: Kalaiela
11 Replies

4. Shell Programming and Scripting

Echo Command Help

Hi All I want to use the echo command to had some lines to a file but the lines i want to have contain " and ; here is my command system("echo user_pref("accessibility.typeaheadfind.flashBar", 0); > $profile"); but i think there are too many " and so it barfs n e ideas thanks A (5 Replies)
Discussion started by: ab52
5 Replies

5. Shell Programming and Scripting

Command substitution in echo

a=1 b1=unix echo $b`$a` The above code is not working. Instead of printing the variable b1 using 'echo $b1', how to use variable 'a' to print 'b1' (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

6. Shell Programming and Scripting

echo & sed problems

I need a script to to instert the following line into my postfix master.cf file: flags=Rq user=filter argv=/etc/postfix/disclaimer -f ${sender} -- ${recipient}if I use echo I get the line truncated: :~ echo flags=Rq user=filter argv=/etc/postfix/disclaimer -f ${sender} -- ${recipient}... (3 Replies)
Discussion started by: barrydocks
3 Replies

7. Shell Programming and Scripting

What does following echo command do?

Can anybody tell me what does following command do? # echo gsoc1 | ./configure_cmd.sh Regards, akash mahakode (1 Reply)
Discussion started by: akash_mahakode
1 Replies

8. UNIX for Dummies Questions & Answers

Echo command with $$ $# $@

Hi, Good morning. Would you please explain to me what does it mean by the following command. echo "$$ $# $@" >> /opt/ftp_generic_send.log I know that something is being directed to log file, but not sure what exactly mean by those $$ and $# and $@ means. Thank you for your help.... (3 Replies)
Discussion started by: howdy
3 Replies

9. Shell Programming and Scripting

what does echo $$ command display

whats the value stored in $$ (2 Replies)
Discussion started by: suri
2 Replies

10. AIX

Echo Command to Tape

I've just got a new server running AIX5.3 When I Try this command: echo ABC123 > /dev/rmt0 I get the following message : A system call received a parameter that is not valid It worked OK on 4.3. Has something changed in the operating system> (0 Replies)
Discussion started by: gordbaby
0 Replies
Login or Register to Ask a Question