Sponsored Content
Full Discussion: Bash to exit on no reponse
Top Forums Shell Programming and Scripting Bash to exit on no reponse Post 302980659 by RavinderSingh13 on Wednesday 31st of August 2016 10:51:11 AM
Old 08-31-2016
Hello cmccabe,

Could you please try following.
Code:
read -r -p "Is this correct? [yes/No] " response
if [[ $response =~ ([no]||[NO]||[No]||[nO]) ]]
then
    echo "The files do not match"
        exit
else
        echo ".... do something";
fi

It sees for string entered from users like No,nO,NO,no too.

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Functions, exit, and kill in bash

Hello Okay, for reasons related to sourcing a script from another script, I've had to put my main loop into a function, and from there I call other functions. My problem then is exiting from deep within the function call stack. I used to simply call exit, and that would accomplish what I... (1 Reply)
Discussion started by: brsett
1 Replies

2. Shell Programming and Scripting

CGI shell script curl reponse problem

Hi, I am running a bash shell script for some simple web server CGI, the script runs as expected from the browser except the following: curl --silent --max-time 10 --output /dev/null --write-out %{http_code} http://server:port/filename This line outputs 404 when i execute the script... (0 Replies)
Discussion started by: Moxy
0 Replies

3. Shell Programming and Scripting

Quitting a bash script... any alternatives to exit?

Folks, Below is a basic synopsis of the problem. I have a script that I need to check for some env vars and fail (exit the script) if they are not there. At the same time I need to set some default env vars. To do this I must run the script from the parent shell or source the script. Doing... (3 Replies)
Discussion started by: bashN00b
3 Replies

4. Shell Programming and Scripting

Bash script wont exit?

Solved Stupidly I didn't put brackets around the , thanks for all the help guys if ps ax | grep Cluster__check.bash | grep -v grep > /dev/null -- fails (if ps ax | grep Cluster__check.bash | grep -v grep > /dev/null) --works (3 Replies)
Discussion started by: danmc
3 Replies

5. Shell Programming and Scripting

Bash Shell Script Exit Codes

Here is my daily stupid question: How can I tell a script to only execute if the other scripts exits successfully? So "script A" executes and it executes successfully (0),then "script B" will run or else "script A "executes and it exits unsucessfully (1) then "script B" will read return... (6 Replies)
Discussion started by: metallica1973
6 Replies

6. Shell Programming and Scripting

Bash won't exit as expected

Hi there, following code snippet should output nothing, IMHO. But the result is "THE END". #!/bin/bash if true ; thenexit fi | grep "somesearchstring" echo "THE END"using bash 4.1.9(1) Bug or feature? Hagen (5 Replies)
Discussion started by: montour
5 Replies

7. Shell Programming and Scripting

Global exit listener in bash

I have a script with a whole lot of different functions and want to set teh script so that at any point a key or series of keys can be pressed to exit out and into the main menu function. Rather this than endlessly creating, 'Return to main' menus. Something along the lines of Ctrl+q for example... (1 Reply)
Discussion started by: 3therk1ll
1 Replies

8. Ubuntu

Exit user in bash script

I'm writing a bunch of scripts to automatically configure Ubuntu and I want to run the code below to remove the white dots from the login screen: sudo xhost +SI:localuser:lightdm sudo su lightdm -s /bin/bash gsettings set com.canonical.unity-greeter draw-grid false The problem is that... (3 Replies)
Discussion started by: maerlyngb
3 Replies

9. Red Hat

No reponse to 'service NFS start' command

Hello, I have a newly kickstarted RHEL 6.4 server that I'm trying to set-up as a kickstart server. I have done this before on other machines, but I am encountering some strange behaviour in this one. # service nfs status rpc.svcgssd is stopped rpc.mountd is stopped nfsd is stopped... (0 Replies)
Discussion started by: Chopstyx
0 Replies

10. Shell Programming and Scripting

Returning an exit code from a bash function

How to return a exit code from a function and use it in conditional? I tried the following but it does not seem to work. tests.sh: if test ./load.sh ; then echo "0" else echo "1" fi load.sh: return 1; from command line: $ ./tests.sh 0 I was expecting it to output "1"... (17 Replies)
Discussion started by: wolfv
17 Replies
LOCALE_FILTER_MATCHES(3)						 1						  LOCALE_FILTER_MATCHES(3)

Locale::filterMatches - Checks if a language tag filter matches with locale

	Object oriented style

SYNOPSIS
publicstatic bool Locale::filterMatches (string $langtag, string $locale, [bool $canonicalize = false]) DESCRIPTION
Procedural style bool locale_filter_matches (string $langtag, string $locale, [bool $canonicalize = false]) Checks if a $langtag filter matches with $locale according to RFC 4647's basic filtering algorithm PARAMETERS
o $langtag - The language tag to check o $locale - The language range to check against o $canonicalize - If true, the arguments will be converted to canonical form before matching. RETURN VALUES
TRUE if $locale matches $langtag FALSE otherwise. EXAMPLES
Example #1 locale_filter_matches(3) example <?php echo (locale_filter_matches('de-DEVA','de-DE', false)) ? "Matches" : "Does not match"; echo '; '; echo (locale_filter_matches('de-DE_1996','de-DE', false)) ? "Matches" : "Does not match"; ?> Example #2 OO example <?php echo (Locale::filterMatches('de-DEVA','de-DE', false)) ? "Matches" : "Does not match"; echo '; '; echo (Locale::filterMatches('de-DE-1996','de-DE', false)) ? "Matches" : "Does not match"; ?> The above example will output: Does not match; Matches SEE ALSO
locale_lookup(3). PHP Documentation Group LOCALE_FILTER_MATCHES(3)
All times are GMT -4. The time now is 05:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy