Sponsored Content
Top Forums Shell Programming and Scripting Require input in bash dialog box Post 302994103 by Scrutinizer on Sunday 19th of March 2017 03:01:37 AM
Old 03-19-2017
Hi, case statements cannot use regular expressions, they use pattern matches, which have a different syntax.

Since there is no specification in this thread of what shell is going to be used, this is the best option, because a case statement works in any POSIX shell or even Bourne shell.

If your shell supports regex (modern Bash, ksh93, zsh) then you could do this (using the original example):

Code:
trap clear EXIT
DIALOG=${DIALOG=dialog}
while :
do
  rfcval=$($DIALOG --title "RFC NUMBER" --clear \
          --inputbox "Please enter an RFC Number" 16 17 2>&1 >/dev/tty)
  retval=$?
  case $retval in
    0)
      if [[ $rfcval =~ ^[0-9]{5,}$ ]]; then
        echo "RFC Number: $rfcval" >> $accessfile
        break
      elif [[ $rfcval =~ ^(N/A|n/a)$ ]]; then
        break
      fi ;;
    1)
      exit 1;;
    255)
      rm -f "$accessfile" "$tempfile" "$sitefile"
      exit 1 ;;
  esac
done
exit 0

-- edit --
Just noticed the thread title mentions bash, oh well Smilie ...

Last edited by Scrutinizer; 03-19-2017 at 06:18 AM..
This User Gave Thanks to Scrutinizer For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Displaying a dialog box using terminal commands

Hello, I used the command osascript -e 'tell app "Finder" to display dialog "Hey!"' to display a dialog box..it works fine, it displays a dialog box with 'OK' and 'CANCEL' buttons..i want to get the button returned value how can i do that using terminal command? is there any command to get... (1 Reply)
Discussion started by: keshav.murthy@r
1 Replies

2. Shell Programming and Scripting

Pop up dialog box on remote computers

I need to send out messages to over 100 clients in my sector. I want it to pop up a dialog box letting them know to save work and log out. I have the reboot script created just need the warning please. Thanks (35 Replies)
Discussion started by: deaconf19
35 Replies

3. Shell Programming and Scripting

Unix / Linux Dialog Utility - how to open 2+ more dialog windows ?

Hi, example of Unix / Linux dialog utility is below. I am going to use dialog as simple GUI for testing of a modem. So I need to combine some dialog boxes into one. I need to have input box, output box, info box, dialog box, radiobox as in any standard program with graphical user... (2 Replies)
Discussion started by: jack2
2 Replies

4. Debian

Dialog box in debconf file.

Hi all, I am working with debconf file for packaging the projects. I have used the ". /usr/share/debconf/confmodule" file to do the packaging in debian standard. It worked fine. When ever I am installing the package in apt-get the dialogs are come as I mentioned in the templates file.... (0 Replies)
Discussion started by: Nila
0 Replies

5. Shell Programming and Scripting

Script to display a dialog box every 5 seconds

I want to create a script that displays a dialog box every interval of time and exits that loop when a user presses ENTER Any idies? (4 Replies)
Discussion started by: amitlib
4 Replies

6. Red Hat

Authentication Failed Dialog Box on Redhat 4.7

For some reason i cannot login using root or other accounts on my Linux system. When logging in at the main console it says "Authentication failed" in a dialog box with an OK button. The Linux system is Redhat 4.7. I've already checked /etc/pam.d/login, /etc/security/access.conf and ... (27 Replies)
Discussion started by: redhatuser2012
27 Replies

7. Shell Programming and Scripting

How to create multiple input box in same window using dialog

Hi All, I was trying to generate GUI using shell script. After long search I found the utility called “dialog”. Using this utility I am able to generate window to collect the input. dialog --inputbox "Input 1" 10 45 dialog --inputbox "Input 2" 10 45 dialog --inputbox "Input 3" 10 45 Using... (2 Replies)
Discussion started by: kalpeer
2 Replies

8. UNIX for Dummies Questions & Answers

Dialog box

I know, I can run dialog command in my machine. But what I want to do is I wanna show the dialog box to some other Remote host. I connected to the remote system and used dialog command its shows the box in my terminal only. How can I display to that remote machine?? Any suggestions??? (3 Replies)
Discussion started by: Adhi
3 Replies

9. Shell Programming and Scripting

Dialog box in korn shell scripting

Does dialog box works on all kind of shells? I am using korn shell in Linux . For me dialog is not working :) is there any particular syntax or do we need to have particular OS version or shell env? #!/bin/ksh dialog --title "create file" \ --backtitle "shell script practice" \... (1 Reply)
Discussion started by: NarayanaPrakash
1 Replies

10. Shell Programming and Scripting

Dynamic Bash Dialog from directory listing

Hey! I want to get a directory listing and turn it into a bash dialog menu. I need to append information from the files themselves (they'll be text files) onto the actual filenames as well. I want to feed the appended filename list into the dialog menu as options. I need to make a case... (5 Replies)
Discussion started by: shrout1
5 Replies
EXIT(P) 						     POSIX Programmer's Manual							   EXIT(P)

NAME
exit - cause the shell to exit SYNOPSIS
exit [n] DESCRIPTION
The exit utility shall cause the shell to exit with the exit status specified by the unsigned decimal integer n. If n is specified, but its value is not between 0 and 255 inclusively, the exit status is undefined. A trap on EXIT shall be executed before the shell terminates, except when the exit utility is invoked in that trap itself, in which case the shell shall exit immediately. OPTIONS
None. OPERANDS
See the DESCRIPTION. STDIN
Not used. INPUT FILES
None. ENVIRONMENT VARIABLES
None. ASYNCHRONOUS EVENTS
Default. STDOUT
Not used. STDERR
The standard error shall be used only for diagnostic messages. OUTPUT FILES
None. EXTENDED DESCRIPTION
None. EXIT STATUS
The exit status shall be n, if specified. Otherwise, the value shall be the exit value of the last command executed, or zero if no command was executed. When exit is executed in a trap action, the last command is considered to be the command that executed immediately preceding the trap action. CONSEQUENCES OF ERRORS
Default. The following sections are informative. APPLICATION USAGE
None. EXAMPLES
Exit with a true value: exit 0 Exit with a false value: exit 1 RATIONALE
As explained in other sections, certain exit status values have been reserved for special uses and should be used by applications only for those purposes: 126 A file to be executed was found, but it was not an executable utility. 127 A utility to be executed was not found. >128 A command was interrupted by a signal. FUTURE DIRECTIONS
None. SEE ALSO
Special Built-In Utilities COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 EXIT(P)
All times are GMT -4. The time now is 12:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy