Register
It is currently Sat Nov 29, 2014 2:30 am

Interactive menu


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Wed Apr 08, 2009 1:58 pm   

Joined: Wed Apr 08, 2009 12:41 pm
Posts: 15
Hello,

Currently I am working on a small project and I need help with MyScript. I wrote a simple script (lets call it MyScript) to update certain applications on my Linux box. The script runs just fine, but I need to take it to the next level and make it more interactive. I need the script to carry out the following:

Present the user with a dialog "screen/window" to select either one or multiple applications to install/upgrade. Hence, the script will install/update the selected applications, only.

Let's say I wan to upgrade Exim, Php, and httpd -- MyScript menu allows me to select either one, two, or all of them.

Let's say I am trying to upgrade exim. Before MyScript start downloading the tar ball package, MyScript will compare the current version installed on the server:
a) if the same, MyScript will say, "Your current mail server is up-to-date.";
b) If old, MyScript will download and install the new version:

So, the menu can use a loop, something like the code written by jbsnake (Intermediate Bash Tutorial): http://bashscripts.org/viewtopic.php?t=40

Code:
#!/bin/bash

   ### start main ###
   echo "Please choose one of the following:"
   echo "1) Install/Upgrade Exim"
   echo "2) Install/Upgrade Php v5.x"
   echo "3) Install/Upgrade MySQL v6.x"
   echo "4) More Applications"
   echo "0) Exit"
   read choice
       
   while [[ $choice != 0 ]]
   do
      case $choice in
         1)   clear;
   wget -o http://ftp.exim.llorien.org/exim/exim4/exim-4.69.tar.gz
   tar xzf exim-4.69.tar.gz
   cd exim-4.69
   ./conifgure
   ./make
   ./make install
            ;;
         2)   clear;
            UPGRADE PHP;
            ;;
         3)   clear;
            UPGRADE MySQL;
            ;;
         4)   clear;
            MORE APPS;
            ;;
         0)   clear;
            echo "Returning to command line . . .";
            exit;
            ;;
         *)   clear;
            echo "Not a valid selection!";
            ;;
      esac
      echo "Please choose one of the following:"
      echo "1) Install/Upgrade Exim"
      echo "2) Install/Upgrade Php v5.x"
      echo "3) Install/Upgrade MySQL v6.x"
      echo "4) More Applications"
      echo "0) Exit"
      read choice
   done


This script will run on CentOS, Fedora Core, and RedHat.

Any help is greatly appreciate. I am even willing to pay for your time. Thank you

Kal


Top
 Profile  
 PostPosted: Mon Aug 17, 2009 2:29 am   

Joined: Mon Aug 17, 2009 2:11 am
Posts: 4
Use the select statement. It combines the echo, read, while and case statements and will save you a couple of lines of code.
See http://www.tldp.org/LDP/abs/html/testbranch.html#EX31 and/or man bash


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP