Sponsored Content
Full Discussion: Menu with working functions
Top Forums Shell Programming and Scripting Menu with working functions Post 302901661 by Backtickcruise on Wednesday 14th of May 2014 07:55:13 PM
Old 05-14-2014
Menu with working functions

I am creating a menu currently that makes use of functions to complete each selected option but running into a bit of trouble calling them into action still fairly new with using functions correctly so any insight is appreciated. here is my code so far

Code:
 #!/bin/bash
#Last updated on 05/14/14

########################################

 

Function1 () {  
  grep 'who | sed -e 's/ *.//' | sort -u' addressfile.txt | cut -d: -f2,6 }

 

Function2 () {

Ps -u $usrname | awk ‘{print $2}' }             

 

Function3 () {

cut -d: -f1 addressfile.txt | uniq -d }

 

Function4 () {

awk - f`:` ‘{print $2”,”$3“,”$4”,”$6”,”}`addressfile.txt }


Function5 () {

for x in `ls /export/home`

do

     echo “$x `ls /export/home/$x | wc -l` ” >>violators

 

done

     sort -r -k2 violators | head -5

     rm violators }

 

ans="y"
while [ $ans != "x" ]
do
clear
echo "            Admin Menu"
echo "            ----------"
      echo "A: Get active user phone numbers?" 
      echo "B: Stop user processes?" 
      echo "C: Check for double IDs?" 
      echo "D: Print Users?" 
      echo "E: Warn power users?" 
      echo "Type x to exit" 
      echo -n "Enter a selection: "
read letter
case "$letter" in
a|A) 
echo "Option A: "; Function1;;
echo "Hit ENTER to continue"
read more
;;

b|B)
echo "Option B "  Function2;;
echo "Hit ENTER to continue"
read more
;;

c|C)
echo "Option C " Function3;;
echo "Hit ENTER to continue"
read more
;;

d|D)
echo "Option D " Function4;;
echo "Hit ENTER to continue"
read more
;;

e|E)
echo "Option E" Function5;;
echo "Hit ENTER to continue"
read more
;;

x)
exit
;;

*) echo " You did not enter valid command "
echo "Hit ENTER to continue"
read more
esac
done

 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

functions not working

I have the following functions but when I run SelectQmgr from a Menu Selection it doesn't do anything. SelectQmgr () { qmgrlist=`ls /var/mqm/qmgrs/ | grep -v @SYSTEM` qmgrcount=`ls /var/mqm/qmgrs/ | grep -v @SYSTEM | wc -l` if then echo "$qmgrlist QManager will be used " ... (7 Replies)
Discussion started by: darthur
7 Replies

2. Shell Programming and Scripting

Menu in Menu script issue

Problem: I am trying to create a menu in a menu script and I am running into an issue with the calculator portion of the script. I am first presented with the ==Options Menu== which all 5 options working correctly. Now comes the fun part. I select option 1 which takes me to my ==Calculator... (1 Reply)
Discussion started by: iDdraig
1 Replies

3. Shell Programming and Scripting

Menu with sub-menu options

Hi! I have created on script which is working fine with menu options and with a sub-menu. I want to enhance it by using sub-options under menu options. Like. option 1) will give the list only. option 1.1) should give the option to user to choose one file, whose content user wanna see. ... (3 Replies)
Discussion started by: sukhdip
3 Replies

4. Shell Programming and Scripting

Need help in create menu with 3 sub menu using the case command

hi all i am a newbie to this is there any examples on creating a main menu with 3 sub menu main menu -> option a , b and c a menu -> option 1 ,2 and 3 b menu -> option 1 ,2 c menu -> option 1 ,2 i am getting headache as my code kept getting unexpected EOF ---------- Post... (0 Replies)
Discussion started by: chercm
0 Replies

5. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

6. Programming

Working of exec family of functions

Hi, I am studying exec family of functions.Its man page says,it replaces the current process image with a new process image. If it replaces the binary,then after returning back,how does it get the previous parameters of the process which called exec?As replacing process image means replacing all... (1 Reply)
Discussion started by: Radha.Krishna
1 Replies

7. UNIX for Dummies Questions & Answers

Working of exec family of functions

Hi, I am studying exec family of functions.Its man page says,it replaces the current process image with a new process image. If it replaces the binary,then after returning back,how does it get the previous parameters of the process which called exec?As replacing process image means replacing... (5 Replies)
Discussion started by: Radha.Krishna
5 Replies

8. UNIX for Beginners Questions & Answers

Gnome 3.28.3 menu item dissapears under the system menu

I installed CentOS 8 with Gnome 3.28.2 and I noticed that the "switch user" menu item disappeared from under the system menu of Gnome classic (Both X11 & Wayland). I checked google and this problem seems to have a history going back several releases of Gnome. Unfortunately, I never found a... (1 Reply)
Discussion started by: bodisha
1 Replies
getitems(1F)							   FMLI Commands						      getitems(1F)

NAME
getitems - returns a list of currently marked menu items SYNOPSIS
getitems [delimiter_string] DESCRIPTION
The getitems function returns the value of lininfo if defined, else it returns the value of the name descriptor, for all currently marked menu items. Each value in the list is delimited by delimiter_string. The default value of delimiter_string is newline. EXAMPLES
Example 1: A sample output of getitems command. The done descriptor in the following menu definition file executes getitems when the user presses ENTER (note that the menu is multise- lect): Menu="Example" multiselect=TRUE done=`getitems ":" | message` name="Item 1" action=`message "You selected item 1"` name="Item 2" lininfo="This is item 2" action=`message "You selected item 2"` name="Item 3" action=`message "You selected item 3"` If a user marked all three items in this menu, pressing ENTER would cause the following string to be displayed on the message line: Item 1:This is item 2:Item 3 NOTES
Because lininfo is defined for the second menu item, its value is displayed instead of the value of the name descriptor. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5) SunOS 5.10 5 Jul 1990 getitems(1F)
All times are GMT -4. The time now is 11:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy