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
SSH2_METHODS_NEGOTIATED(3)						 1						SSH2_METHODS_NEGOTIATED(3)

ssh2_methods_negotiated - Return list of negotiated methods

SYNOPSIS
array ssh2_methods_negotiated (resource $session) DESCRIPTION
Returns list of negotiated methods. PARAMETERS
o $session - An SSH connection link identifier, obtained from a call to ssh2_connect(3). RETURN VALUES
EXAMPLES
Example #1 Determining what methods were negotiated <?php $connection = ssh2_connect('shell.example.com', 22); $methods = ssh2_methods_negotiated($connection); echo "Encryption keys were negotiated using: {$methods['kex']} "; echo "Server identified using an {$methods['hostkey']} with "; echo "fingerprint: " . ssh2_fingerprint($connection) . " "; echo "Client to Server packets will use methods: "; echo " Crypt: {$methods['client_to_server']['crypt']} "; echo " Comp: {$methods['client_to_server']['comp']} "; echo " MAC: {$methods['client_to_server']['mac']} "; echo "Server to Client packets will use methods: "; echo " Crypt: {$methods['server_to_client']['crypt']} "; echo " Comp: {$methods['server_to_client']['comp']} "; echo " MAC: {$methods['server_to_client']['mac']} "; ?> SEE ALSO
ssh2_connect(3). PHP Documentation Group SSH2_METHODS_NEGOTIATED(3)
All times are GMT -4. The time now is 06:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy