Computing.Net > Forums > Unix > test for field existence

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

test for field existence

Reply to Message Icon

Name: camin
Date: May 10, 2004 at 13:48:56 Pacific
OS: SunOS 5.8 Generic_108528-
CPU/Ram: unknown
Comment:

Hi,

Can someone please help! How do test to see if a field exist?
The script is very long too long to paste in here:
bugval is a ClearDDts command its just getting the field value from an sql database.

The conditions are that the field exist and has a value of "no"

man27=`$home/bin/bugval -i $i est27`
if test $man27 = no && test X"$man27" != X
then
ma27=`$home/bin/bugval -i $i other3`
echo $i >>$tempdir/w_$ma27.txt
echo $ma27 >>$tempdir/w_man.txt
fi
thanks for any help.
camin



Sponsored Link
Ads by Google

Response Number 1
Name: Jim Boothe
Date: May 11, 2004 at 10:14:03 Pacific
Reply:

Since man27 might be null, you need to enclose it in quotes to avoid a script error:

if test "$man27" = no && test X"$man27" != X

Your test of man27 for not null is fine, except that it is redundant here. When man27 contains your required value of "no", that means also that it cannot possibly be null.

Other ways to check for non-null:

if test "$man27" != ""

if test -n "$man27"


0

Response Number 2
Name: camin
Date: May 12, 2004 at 09:11:18 Pacific
Reply:

thanks Jim...


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: test for field existence

testing for hardlinks www.computing.net/answers/unix/testing-for-hardlinks/5048.html

Test for FileName www.computing.net/answers/unix/test-for-filename/7668.html

FTP problems www.computing.net/answers/unix/ftp-problems/3928.html