Bash Script - Whiptail Menu Help!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash Script - Whiptail Menu Help!
# 8  
Old 07-15-2014
Alright got it.

The following code doesn't seem to be working

Code:
#!/bin/bash
clear

whiptail --msgbox "Entering networking sub-menu" 20 78

CHOICE=$(
whiptail --title Networking --menu "Make your choice" 16 78 5 \
  "1)" "Display info" 3>&2 2>&1 1>&3 
)
case $CHOICE in
  "1)") ./displayinfo.sh
esac

However, the one that directed to "somefile" works just fine. Therefore, i'll stick to that code as it is clearer.

----------------------------------------------------------------

And, there's one more question that i would like to ask.

Basically, i have two network card installed and i would like the code display the information of the selected network card and to display only available network card as the choices for the user. How do i go about doing that in Whiptail?

I tried doing it in "Select" and it work like this.

Code:
#!/bin/bash
clear

presentNIC=$(ifconfig -a | sed -n 's/^\([^ ]\+\).*/\1/p')

echo "Present NIC: "
echo ""
echo $presentNIC
echo ""

read -p "Which NIC?" ansNIC

echo ""
echo $(ifconfig $ansNIC)
echo ""

And when i tried to do it in the Whiptail, the answer stack as one choice... someone guide me pls.


Code:
#!/bin/bash
clear

presentNIC=$(ifconfig -a | sed -n 's/^\([^ ]\+\).*/\1/p')

whiptail --title "Networking" --menu "Make your choice" 16 78 5 \
"1." "$presentNIC" 2>somefile
CHOICE=$(cat somefile)
             case $CHOICE in
             "1)") *link it to chosen network card* ;;
             esac


Last edited by Scrutinizer; 07-15-2014 at 09:30 AM.. Reason: CODE tags
# 9  
Old 07-15-2014
Stacked as one choice
Bash Script - Whiptail Menu Help!-untitledjpg
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing positioning array as whiptail -- menu option

I may have asked this before, so forgive OF. Problem: I can pass positioning array as -- menu option to whiptail, but it does not show in the whiptail form as an array - only single (first member "lsusb" ) entry / line shows up. Code: DynamicEntry=$(whiptail \ --title "DEBUG... (1 Reply)
Discussion started by: annacreek
1 Replies

2. Shell Programming and Scripting

Redirecting stdout output to whiptail menu box

As a result of whiptail menu option I am getting a data from a file. Naturally it is output to terminal as stdour. I like to redirect the output back to the menu. It can be done with single input of line of text , see attached. I just cannot see where or how the sample... (0 Replies)
Discussion started by: annacreek
0 Replies

3. Shell Programming and Scripting

Creating bash script to process a data file based on the menu

Hey, im fairly new to unix and Im trying to make this unix project that would display a menu and do the following. MENU =========================== (p, P) Print users info (a, A) Add new user (s, S) Search user (d, D) Delete user (x,X) Exit Enter your choice: Trying to... (3 Replies)
Discussion started by: ultimaxtrd
3 Replies

4. Shell Programming and Scripting

Menu Driven Bash Shell Script with Default Option

Hi All, I have written a menu driven bash shell script. Current Output is as below: ------------------------------------- Main Menu ------------------------------------- Option 1 Option 2 Option 3 Option 4 Exit ===================================== Enter your... (3 Replies)
Discussion started by: kiran_j
3 Replies

5. UNIX for Dummies Questions & Answers

Simple bash script menu

Dear Sir, May I know how do I go about adding the following feature into the script below: When user enter values other than 1,2,3,4, a) Message “Wrong entry !!! Pls select 1,2,3 or 4” is displayed b) The screen is cleared again and the menu is displayed. #!/bin/bash clear var=1... (2 Replies)
Discussion started by: fusetrips
2 Replies

6. Shell Programming and Scripting

Whiptail menu, getting back the variable

Hi all Only learning so if any mistakes, let me know I am trying to create a menu box with Whiptail, taking in the variables from a txt.file called Name.txt which has just 4 names listed for now, one below each other..ie Dave John Mike Mary Bash script is below and calls the txt... (8 Replies)
Discussion started by: olearydc
8 Replies

7. 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

8. Shell Programming and Scripting

Help regarding a bash menu script

Greetings all, I'm having some trouble writing a menu drive bash script, actually coding the menu part was not difficult however its a problem with a menu option I'm having trouble with. My menu has 5 options, when the user selects the second option, they are then prompted to enter a number from... (5 Replies)
Discussion started by: Vitrophyre
5 Replies

9. Shell Programming and Scripting

Execute interactive bash menu script in browser with PHP

I have an interactive menu script written in bash and I would like use PHP to open the interactive bash menu in a browser. Is this possible? Using the sytem() function in php runs the script but it's all garbled. Seems like maybe a terminal window needs to be opened in php first? ... (1 Reply)
Discussion started by: nck
1 Replies

10. Shell Programming and Scripting

Bash menu script

I have a main menu quit=n while do clear echo echo "1. General system information" echo "2. Hardware utilisation information" echo "3. File management" echo "4. User information" echo "5. Information on network connectivity" echo "6. Information on processes" echo "Q.Quit" ... (3 Replies)
Discussion started by: AngelFlesh
3 Replies
Login or Register to Ask a Question