Sponsored Content
Top Forums Shell Programming and Scripting [Solved] If doesn't evaluate the first test Post 302746091 by Chubler_XL on Tuesday 18th of December 2012 06:34:21 PM
Old 12-18-2012
OK bash string comparisons are case sensitive so Yes and yes are different.

You can either put:

Code:
shopt -s nocasematch

before the compare to ignore case and revert to case sensitive with shopt -u nocasematch

or compare with the correct case version (eg "yes" instead of "Yes")
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

2. Programming

Kernel module - How to test if file doesn't exist

Hey, I'm currently getting into some kernel module progamming. As a little exercise I want to read the headers out of an ELF file. My code is very simple, here is the important part: struct file *fp; /* ... */ fp = filp_open("some/file/on/my/pc", O_RDONLY, 0); if(fp == NULL) { ... (15 Replies)
Discussion started by: disaster
15 Replies

3. Shell Programming and Scripting

[Solved] Bash test 2 variables to see if ones greater by n

Experts, I have a bash shell script that generates 2 variables that have the current minute and a minute from a log file. Can someone please show me the best way to test if the minutes stray by 5. So basically if: This is ok: Last Fitting Min ============= 02 Current Minute =============... (2 Replies)
Discussion started by: jaysunn
2 Replies

4. Shell Programming and Scripting

Value of variable is NULL, but test doesn't seem to recognize

Hello, Unix-forums! My problem: read -p "Enter any number, please" number sleep 1 echo $number | tr -d 0-9 test -z $number && echo "Thank you" || echo "This is not a number"Test always displays "This is not a number". It doesn't matter if I entered a or 1. But if I order echo... (2 Replies)
Discussion started by: intelinside
2 Replies

5. Shell Programming and Scripting

[Solved] BASH - chaining TEST and COMMAND with && and II

Can you explain what this line of script is doing. What I have understood is : -- variable C is the name of a software which is either not installed, so it must be installed or allready installed and then should be update if newer version found -- branch B="$B $C" is to install the software --... (4 Replies)
Discussion started by: jcdole
4 Replies

6. Shell Programming and Scripting

[Solved] Script doesn't work..help?

hi, i am trying to run this script.the name of script is final.sh after i run it: #./final.sh & i grep the command # ps -a | grep bash and i see more then one processes runing 3!! Please use code tags how can i solve this problem? my target script must always run in... (8 Replies)
Discussion started by: zigizag
8 Replies

7. UNIX for Dummies Questions & Answers

[Solved]Can anyone tell me why -H flag with sudo doesn't switch to the target user's home directory?

I have checked the man page ,which says : The -H (HOME) option sets the HOME environment variable to the homedir of the target user (root by default) as specified in passwd(5). By default, sudo does not modify HOME But I have tried below command: #... (1 Reply)
Discussion started by: Michaelw321
1 Replies

8. Shell Programming and Scripting

[solved] awk: test assoc. array for content

Hi all, I am looking for a quick/short way in awk to check if an associative array has any content. I know I can split() it to an indexed array and check if the 1st element is set, or cycle through it with something like for( ele in arr ), but I want to avoid that, as I am looking for a shorter... (3 Replies)
Discussion started by: zaxxon
3 Replies

9. UNIX for Dummies Questions & Answers

[Solved] Custom actions in Thunar doesn't display at all.

I have came across a few websites stating some custom actions for Thunar - crunchbang ubuntu I tried inputting the stated commands to Thunar, but it doesn't display at all in mine. I tried "gksu thunar %f" ( Opens current folder with root permissions.) , but when I right click in a... (0 Replies)
Discussion started by: Hijanoqu
0 Replies

10. Shell Programming and Scripting

How to test that a string doesn't contain specific characters?

Hi ! :) I made this : #!/bin/bash rsa_dir="/etc/openvpn/easy-rsa/" rsa_key_dir="/etc/openvpn/easy-rsa/keys/" ccd_dir="/etc/openvpn/ccd/" regex_special_char='' cd $rsa_dir while read -p "Please can you enter the vpn's username : " username ] || ] || ] || ] do echo "Your entry... (10 Replies)
Discussion started by: Arnaudh78
10 Replies
MicroMason::TextTemplate(3pm)				User Contributed Perl Documentation			     MicroMason::TextTemplate(3pm)

NAME
Text::MicroMason::TextTemplate - Alternate Syntax like Text::Template SYNOPSIS
Instead of using this class directly, pass its name to be mixed in: use Text::MicroMason; my $mason = Text::MicroMason::Base->new( -TextTemplate ); Use the standard compile and execute methods to parse and evalute templates: print $mason->compile( text=>$template )->( @%args ); print $mason->execute( text=>$template, @args ); Text::Template provides a syntax to mix Perl into a text template: { my $hour = (localtime)[2]; my $daypart = ( $hour > 11 ) ? 'afternoon' : 'morning'; '' } Good { $daypart }, { $name }! DESCRIPTION
This mixin class overrides several methods to allow MicroMason to emulate the template syntax and some of the other features of Text::Template. Compatibility with Text::Template This is not a drop-in replacement for Text::Template, as the Perl calling interface is quite different, but it should be able to process most existing templates without major changes. This should allow current Text::Template users to take advantage of MicroMason's one-time compilation feature, which in theory could be faster than Text::Template's repeated evals for each expression. (No benchmarking yet.) Contributed patches to more closely support the syntax of Text::Template documents would be welcomed by the author. Template Syntax The following elements are recognized by the TextTemplate lexer: o literal_text Anything not specifically parsed by the below rule is interpreted as literal text. o { perl_expr } A Perl expression to be interpolated into the result. Good { (localtime)[2]>11 ? 'afternoon' : 'morning' }. The block may span multiple lines and is scoped inside a "do" block, so it may contain multiple Perl statements and it need not end with a semicolon. Good { my $h = (localtime)[2]; $h > 11 ? 'afternoon' : 'morning' }. To make a block silent, use an empty string as the final expression in the block. { warn "Interpreting template"; '' } Hello there. Although the blocks are not in the same a lexical scope, you can use local variables defined in one block in another: { $phase = (localtime)[2]>11 ? 'afternoon' : 'morning'; '' } Good { $phrase }. Argument Passing Like Text::Template, this package clobbers a target namespace to pass in template arguments as package variables. For example, if you pass in an argument list of "foo => 23", it will set the variable $foo in your package. The strict pragma is disabled to facilitate these variable references. Internally, this module inherits this functionality from the PassVariables mixin. If you are using the TextTemplate mixin, do not also specify the PassVariables mixin or it will be included twice. For more information, see Text::MicroMason::PassVariables. Supported Attributes package Target package namespace. Private Methods prepare() If a package has not been specified, this method generates a new package namespace to use only for compilation of a single template. lex() Lexer for matched braces - produces only text and expr tokens. Uses Text::Balanced. SEE ALSO
The interface being emulated is described in Text::Template. For an overview of this templating framework, see Text::MicroMason. This is a mixin class intended for use with Text::MicroMason::Base. For distribution, installation, support, copyright and license information, see Text::MicroMason::Docs::ReadMe. perl v5.10.1 2007-01-29 MicroMason::TextTemplate(3pm)
All times are GMT -4. The time now is 12:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy