Been trying to build a menu with whiptail lately. However, my code doesn't seems to be working even though when i compared to other similar code they looks the same.
You need to find out how the second whiptail writes its output. Somehow the output of the second whiptail command needs to be fed into the while-read loop. There is not input into that loop here. Perhaps through a pipe symbol (if that command outputs on stdout)?
--
A short look at the man page of whiptail and the menu option, says it's outputting on stderr. But it also needs stdout to go to the terminal, so a pipe cannot be used)
===EDIT===
(corrected previous sentence (thanks Don). I originally said "background" there, which is wrong I meant "subshell". But also that is not really relevant. What matters is that pipe cannot be used like that, because the command needs stdout to go directly to the terminal..)
So try something like:
Last edited by Scrutinizer; 07-13-2014 at 04:39 AM..
Reason: Corrected background to subshell. Thanks Don...
I have no experience with whiptail other than reading the man page, but I think Scrutinizer is close on the solution to your problem. I am, however, a little confused by his implication that commands in a pipeline are run in the background. Pipelines are run in the foreground unless the pipeline is terminated with an & (which runs all commands in a pipeline in the background).
But, it appears from the man page (although not explicitly stated) that standard output from whiptail is supposed to be the terminal. So, the output of whiptail can't be connected to a pipe. The man page also says that the exit status needs to be checked to determine whether a yes/OK, no/cancel, or error or interrupt was detected. My guess (with no testing since my system doesn't have the whiptail command) would be that you want something like:
The 2>file redirects the standard error output from that command to the file named file.
This User Gave Thanks to Don Cragun For This Post:
You could also try this as a way without an intermediate file, using the fact that in a command substitution stderr is directed to the the terminal. So if we flip stdout and stderr then all should be well:
---
Quote:
Originally Posted by Don Cragun
[..] I am, however, a little confused by his implication that commands in a pipeline are run in the background. Pipelines are run in the foreground unless the pipeline is terminated with an & (which runs all commands in a pipeline in the background).
Hi Don. I meant to say subshell instead of background, but even that is not relevant, what is relevant is that its stdout cannot go to the terminal, which it needs control of. I corrected it in my post. Thanks...
Last edited by Scrutinizer; 07-13-2014 at 05:25 AM..
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)