The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
implementing AVL tree arjunjag High Level Programming 1 07-09-2007 11:16 AM
is there anyway of implementing password aging in NIS? HAA Shell Programming and Scripting 1 04-25-2007 08:05 AM
implementing ftp damn_bkb IP Networking 4 01-04-2007 05:35 PM
Implementing a shell in C jacques83 High Level Programming 1 11-13-2006 10:24 PM
Implementing Concatenation(cat) toughguy2handle High Level Programming 2 09-22-2005 03:10 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-06-2009
warlock129 warlock129 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 38
Implementing Password

I am trying to implement a login screen to the following code how would i go about doing so. I have try to place the password in a variable using if statements which would usually work but as i have the system in a while loop i think i need to find another method.


Code:
#!/bin/bash
#Filename: Assigntest Author: Luke Francis
quit=n
while [ "$quit" = "n" ]
do
  clear
  echo "OPERATOR ADMINISTRATIVE TOOL"
  echo
  echo "1. User Information"
  echo "2. Network Connectivity"
  echo "3. Processes"
  echo "4. System Information"
  echo "5. Hardware Utilization"
  echo "Q. Quit"
  echo
  echo "Which option do you require?"
  read menunumber
case $menunumber in
       1)clear
         echo "USER INFORMATION"
         echo
         echo "1. Registered Users"
         echo "2. Disk Usage"
         echo "3. Last Logins"
         echo "4. Users Currently Logged In"
         echo "5. Total number of users"
         echo "B. Back to Main Menu"
         echo "Q. Quit"
         echo
         echo "Which option do you require?"
         read menunumber2
         case $menunumber2 in
              1)clear
                echo "The users registered on the system are:"
                echo
                awk -F: '{print $1}' /etc/passwd
                echo
                echo "Hit the Enter Key to continue"
                 read junk;;
              2)clear
                echo "Disk Usage is as follows:"
                echo
                du
                echo
                echo "Hit Enter Key to continue"
                read junk;;
              3)clear
                echo "Information on last noted login can be found next to      each username."
                echo
                last
                echo
                echo "Hit Enter Key to continue"
                read junk;;
              4)clear
                echo "Users currently logged in are:"
                echo
                w
                echo
                echo "Hit Enter Key to continue"
                read junk;;
              5)clear
                echo "The total number of users are:"
                echo
                who -q
                echo
                echo "Hit Enter Key to continue"
                read junk;;
              Q|q)clear
                  echo "Are you sure you want to quit? Y/N"
                  read choice1
                  case $choice1 in
                       N|n)clear
                           echo "Hit Enter Key to continue"
                           read junk;;
                       Y|y)quit=y;;
                         *)clear
sleep 1;;
                  esac
                  ;;
         esac
         ;;
       2)clear
         echo "NETWORK CONNECTIVITY"
         echo
         echo "1. NIC Status"
         echo "2. Machine Availability"
         echo "B. Back to Main Menu"
         echo "Q. Quit"
         echo
         echo "Which option do you require?"
         read menunumber4
         case $menunumber4 in
              1)clear
                echo "Information reagrding NIC status can be found below:"
                echo
                /sbin/ifconfig
                echo
                echo "Hit the Enter Key to continue"
                read junk;;
              2)clear
                echo "Available hosts and addresses are shown below:"
                echo
                cat /etc/hosts
                echo
                echo "Hit Enter Key to continue"
                read junk;;
       Q|q)clear
           echo "Are you sure you want to quit? Y/N"
           read choice2
           case $choice2 in
                N|n)clear
                    echo "Hit Enter key to continue"
                    read junk;;
                Y|y)quit=y;;
 *)clear
                sleep 2;;
           esac
           ;;
         esac
          ;;
        3)clear
          echo "PROCESSES"
          echo
          echo "1. Running Processes"
          echo "2. Installed Software"
          echo "B. Back to Main Menu"
          echo "Q. Quit"
          echo
          echo "Which option do you require?"
          read menunumber5
          case $menunumber5 in
               1)clear
                 echo "Current running processes are displayed below"
                 echo
                 ps aux
                 echo
                 echo "Hit Enter key to continue"
                 read junk;;
               2)clear
                 echo "The software currently installed on this host is:"
                 echo
                 rpm -qa
                 echo
                 echo "Hit Enter key to continue"
                 read junk;;
        Q|q)clear
           echo "Are you sure you want to quit? Y/N"
           read choice3
           case $choice3 in
                N|n)clear
                    echo "Hit Enter key to continue"
                    read junk;;
 Y|y)quit=y;;
                  *)clear
                sleep 3;;
           esac
            ;;
         esac
          ;;
        4)clear
          echo "SYSTEM INFORMATION"
          echo
          echo "1. Machine Name"
          echo "2. System Date & Time"
          echo "3. Licensing Information"
          echo "4. Last System Reboot"
          echo "B. Back to Main Menu"
          echo "Q. Quit"
          echo
          echo "Which option do you require?"
          read menunumber6
          case $menunumber6 in
               1)clear
                 echo "The name of the machine is:"
                 uname -m
                 echo
                 echo "Hit Enter key to continue"
                 read junk;;
               2)clear
                 echo "The current date and time is:"
                 echo
                 date
                 echo
                 echo "Hit Enter key to continue"
                 read junk;;
               4)clear
                 echo "The last scheduled system reboot was:"
                 echo
                 who -b
                 echo
echo "Hit Enter Key to continue"
                 read junk;;
               B)read junk;;
               Q|q)clear
                   echo "Are you sure you want to quit? Y/N"
                   read choice4
                   case $choice4 in
                   N|n)clear
                       echo "Hit Enter key to continue"
                       read junk;;
                   Y|y)quit=y;;
                     *)clear
                   sleep 4;;
               esac
             ;;
         esac
         ;;
       5)clear
         echo "HARDWARE UTILISATION"
         echo
         echo "1. Unix Filesystem Usage"
         echo "2. RAM Availability"
         echo "3. Swap Space"
         echo "4. CPU Utility"
         echo "Q. Quit"
         echo
         echo "Which option do you require?"
         read menunumber6
         case $menunumber6 in
              1)clear
                echo "Information regarding usage of the Unix filesystem as requested can be found below:"
                echo
                df -h
                echo
                echo "Hit Enter Key to continue"
                read junk;;
              2)clear
                echo "RAM usage information can be found below:"
echo
                cat /proc/meminfo
                echo
                echo "Hit Enter Key to continue"
                read junk;;
              3)clear
                echo "The amount of free and used Swap space is:"
                echo
                cat /proc/meminfo
                echo
                echo "Hit Enter Key to continue"
                read junk;;
              4)clear
                echo "The first column indicates size of CPU run queue"
                echo
                vmstat
                echo
                echo "Hit Enter Key to continue"
                read junk;;
        esac
        ;;
       Q|q)clear
            echo "Are you sure you want to quit? Y/N"
                   read choice5
                   case $choice5 in
                   N|n)clear
                       echo "Hit Enter key to continue"
                       read junk;;
                   Y|y)quit=y;;
                     *)clear
                   sleep 5;;
              esac
              ;;
  esac
done
clear
echo "Thank you for using the Operator Administrative Tool"

I would like the login screen to appear first, and if the password 12345 was not enetered then a message saying incorrect password would be displayed. I have tried to implement this but am not having much luck. How would this be implemented to the code above? All help is appreciated. Thanks
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0