1 Replies - 371 Views - Last Post: 02 December 2013 - 09:28 PM Rate Topic: -----

#1 AZE2013  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 19
  • Joined: 10-July 13

Any LINUX folk out there. Need advice for Menu based shell script

Posted 02 November 2013 - 09:05 PM

Hi fellow programmers, the segment of script I am about to show is a dialog box which
initiates a menu once it is called from the Linux console. I have to add other menu options,
but having difficulty knowing where to apply these script variants. These other files are,
/etc/fstab, $HOME/.bashrc, /etc/mtab, and others. You can get the idea of your knowledgeable with linux.
Check this piece of script out. This segment does work. But need to get help on implementing
the other files.
1#!/bin/bash
2
3while true
4do
5
6dialog --backtitle "test" --title "new" --menu "some text" 20 50 2 "A" "Display /etc/Password" "exit" "Exit this menu" 2>/tmp/sel.$$
7
8st=$?
9ip=`cat /tmp/sel.$$`
10#rm -f /tmp/sel.$$
11
12if [ $st -eq 0 ]; then
13    if [ $ip = "A" ]; then
14         date>/tmp/file1.$$
15         echo "-------------------------">>/tmp/file1.$$
16         cat /etc/passwd>>/tmp/file1.$$
17         dialog --backtitle "test" --title "Contents of /etc/passwd" --infobox "`cat /tmp/file1.$$`" 0 0
18         read
19
20         rm -f /tmp/file1.$$
21
22    elif [ $ip = "exit" ]; then
23         clear;exit;
24    fi
25else
26    clear;exit;
27fi
28done



Is This A Good Question/Topic? 0
  • +

Replies To: Any LINUX folk out there. Need advice for Menu based shell script

#2 Gorian  Icon User is offline

  • ninja DIC
  • member icon

Reputation: 120
  • View blog
  • Posts: 1,681
  • Joined: 28-June 08

Re: Any LINUX folk out there. Need advice for Menu based shell script

Posted 02 December 2013 - 09:28 PM

first off, instead of using a for loop with elifs, use switches, or cases.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1