Sponsored Content
Top Forums Shell Programming and Scripting Eliminate variable checking in a script Post 302148775 by BMetelsky on Monday 3rd of December 2007 04:13:02 PM
Old 12-03-2007
Quote:
Originally Posted by porter
It's shell specific. I lean to to the pedantic portable side.

Give it a go, see if it makes a difference.

Why does an error stop other variables being set?

Personally I've never heard of variable checking in an assignment statement, how would the shell have any idea what was valid. If what you are saying is correct I could not do...

foo=/new/directory/to/create
mkdir -p $foo
well... thanks for the sanity check. I seems there must have been some special (hidden) characters in the profile. I created a new file and the variables wourk as expected....

unreal-
Thanks
Bob
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

checking a variable is within range

how can i check that a variable is between 0-100, like if i ask a user to input a number between 1-100 and i want to excute commands WHILE that number is between that range or else i will keep asking the user to make another input here's what i got #!/bin/bash echo "Guess my secret number... (2 Replies)
Discussion started by: Poison Ivy
2 Replies

2. Shell Programming and Scripting

checking valid values in variable

I'm using the following in my script. if echo $cpuidle |/usr/bin/egrep ; then when I issue this statement it issues the value of the variable back to stdout which ends up in my output file. Is there a better way to write this? I'm using ksh on solaris 9. (3 Replies)
Discussion started by: MizzGail
3 Replies

3. UNIX for Dummies Questions & Answers

ksh Checking if variable has 5 digits

How could I check if a numeric variable has 5 digits in KSH...I have a zipcode variable that I know will always be 5 digits, and I want to print out an error if it is less or more than 5 digits the problem is that I have it as: if ] but this won't work because the statement doesn't see 0001 as... (3 Replies)
Discussion started by: developncode
3 Replies

4. Shell Programming and Scripting

checking the value of the variable

Does anyone know the quick way to check if the variable contains only numeric characters, for example: A=123445 - correct B=#f123* - incorrect I am in ksh88i Thanks a lot for help -A (1 Reply)
Discussion started by: aoussenko
1 Replies

5. Shell Programming and Scripting

checking variable has value - ksh

hi all, i have a shell (ksh) script where i am reading line by line from a grep command and i wanted to check if the grep command actually returned something or was null. i can do this by using -z : if ; then ..... but this forces me to do something when $myVariable is null when i... (3 Replies)
Discussion started by: cesarNZ
3 Replies

6. Shell Programming and Scripting

Shell script help to eliminate files of todays date

Hi I am very new to shell scripting and have written a script (below). However the directory I am searching will contain a file with a .trn extension each day which I want to eliminate. Each day the file extension overnight will change to trx, if this fails I want to know. Basically what I... (2 Replies)
Discussion started by: richM
2 Replies

7. Shell Programming and Scripting

script to eliminate left and right fields and to get the ouput.

Hi Experts, I have a file as given below and want to filter out the filenames in it , by deleting left and right filds and to have the fllenames (There are spaces in the filename), Sun Jan 11 11:20:10 2009 1 0 /home/output/file2311_recent.list user1 user2 0 done Sun Jan 11 11:20:10 2009 1 0... (10 Replies)
Discussion started by: rveri
10 Replies

8. UNIX for Dummies Questions & Answers

Checking the language variable

This is what I have just entered and received in return: # echo $LANG LANG: Undefined variable. How can this be? I was expecting something like en_US.utf8. Am using FreeBSD 8.2. (2 Replies)
Discussion started by: figaro
2 Replies

9. Shell Programming and Scripting

Script to eliminate files .rlogin

Hi guys, I'm try making to script for eliminate files rlogins. path1='/home/*' for i in `cat /etc/passwd |awk -F: '{print $6}'`; do if test "$i" = "$path1"; then echo $i cd $i if ; then echo "$i/.rhosts detectado"|mail -s "rhosts" root ... (14 Replies)
Discussion started by: nena_redbalon
14 Replies

10. Shell Programming and Scripting

Checking the variable in UNIX

Hi, I have a file abc.txt as ABC,TYU,1.2566 AHG,GJJ,1.898 hgh,FGA,1.854 My program is reading each line and storing the values variables base_cy, quo_cy, ra_amt Need to validate each of them as in: base_cy and quo_cy should be a 3 character alphabet among A-Z, if it is lower case ... (1 Reply)
Discussion started by: infyanurag
1 Replies
typeset(1)                                                         User Commands                                                        typeset(1)

NAME
typeset, whence - shell built-in functions to set/get attributes and values for shell variables and functions SYNOPSIS
typeset [ +- HLRZfilrtux [n]] [ name [ = value]]... whence [-pv] name... DESCRIPTION
typeset sets attributes and values for shell variables and functions. When typeset is invoked inside a function, a new instance of the variables name is created. The variables value and type are restored when the function completes. The following list of attributes may be specified: -H This flag provides UNIX to host-name file mapping on non-UNIX machines. -L Left justify and remove leading blanks from value. If n is non-zero it defines the width of the field; otherwise, it is determined by the width of the value of first assignment. When the variable is assigned to, it is filled on the right with blanks or trun- cated, if necessary, to fit into the field. Leading zeros are removed if the -Z flag is also set. The -R flag is turned off. -R Right justify and fill with leading blanks. If n is non-zero it defines the width of the field, otherwise it is determined by the width of the value of first assignment. The field is left filled with blanks or truncated from the end if the variable is reas- signed. The -L flag is turned off. -Z Right justify and fill with leading zeros if the first non-blank character is a digit and the -L flag has not been set. If n is non-zero it defines the width of the field; otherwise, it is determined by the width of the value of first assignment. -f The names refer to function names rather than variable names. No assignments can be made and the only other valid flags are -t, -u and -x. The flag -t turns on execution tracing for this function. The flag -u causes this function to be marked undefined. The FPATH variable will be searched to find the function definition when the function is referenced. The flag -x allows the func- tion definition to remain in effect across shell procedures invoked by name. -i Parameter is an integer. This makes arithmetic faster. If n is non-zero it defines the output arithmetic base; otherwise, the first assignment determines the output base. -l All upper-case characters are converted to lower-case. The upper-case flag, -u is turned off. -r The given names are marked readonly and these names cannot be changed by subsequent assignment. -t Tags the variables. Tags are user definable and have no special meaning to the shell. -u All lower-case characters are converted to upper-case characters. The lower-case flag, -l is turned off. -x The given names are marked for automatic export to the environment of subsequently-executed commands. The -i attribute can not be specified along with -R, -L, -Z, or -f. Using + rather than - causes these flags to be turned off. If no name arguments are given but flags are specified, a list of names (and optionally the values) of the variables which have these flags set is printed. (Using + rather than - keeps the values from being printed.) If no names and flags are given, the names and attributes of all variables are printed. For each name, whence indicates how it would be interpreted if used as a command name. The -v flag produces a more verbose report. The -p flag does a path search for name even if name is an alias, a function, or a reserved word. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
ksh(1), set(1), sh(1), attributes(5) SunOS 5.10 1 Feb 1995 typeset(1)
All times are GMT -4. The time now is 08:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy