04-09-2009
Hanling values in while loop
Hi,
i have a scenario like
file 1
aaa=ddd
bbb=ccc
ccc =ddd
file 2
aaa=mmm
ttt=yyy
bbb=ggg
using awk function i get the key values for file1 (aaa,bbb,ccc)
sample code
------------
warn_msg=0
call_function() {
while read LINE
do
# key values of file1.txt and file 2.txt is compared, if any invalid parameter, i will set warn_msg=1
if [$? !=0 ]; then
warn_msg=1
fi
done < file2.txt
}
call_function ## calling the function
echo $warn_msg
output
------
0
here the key (ttt) is an invalid parameter.
if any invalid parameter occured within the while loop and if i check the value of warn_msg, it is 1, but after the function completes, the value of warn_msg is assigned to 0 but it should be 1. please provide me an answer.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello guys i'm getting this error on a sco 5.0.7 machine and i have no idea why i'm getting this error.
I know how to encrease the value of NSTRPAGES, right now i have it up to 4000.
I would like to know what is NSTRPAGES and what is causing this error to come up in my server.
Thanks a... (2 Replies)
Discussion started by: josramon
2 Replies
2. HP-UX
Sirs/Madame,
On my HP-Unix, I came across an error GRECV-count exceeded and as a result of this, systems got hanged and server came down. Graceful shutdown too was not allowed.
Kindly, Can anybody help me out in killing this issue
Bhavani.R (0 Replies)
Discussion started by: bhavani2006
0 Replies
3. Shell Programming and Scripting
Hi,
How to write a script which checks the size of a log file?
I want that the log file contents to get cleared as soon as it increases 1 KB.
Thanks (3 Replies)
Discussion started by: skyineyes
3 Replies
4. UNIX for Dummies Questions & Answers
I keep on getting an error on my site saying
I've got a 250GB dedicated server, and have used less than 200mb of that.
The site has only been on the server for just over a month.
What does this mean and how can I sort it? (8 Replies)
Discussion started by: thehaapyappy
8 Replies
5. UNIX for Dummies Questions & Answers
Hey guys...
I'm learning some shell scripting on OS X using the tcsh shell.
For some reason... my while loop isn't executing right (or more likely I am doing something wrong.)
Something as simple as this doesn't work:
#!/bin/tcsh
set g = 0
while ($g <10)
echo "this" $g
@ g =... (2 Replies)
Discussion started by: sprynmr
2 Replies
6. Solaris
what are the major Difference Between run level & init level (2 Replies)
Discussion started by: rajaramrnb
2 Replies
7. Shell Programming and Scripting
Hi. I am receiving this error message for the highlighted line (let "total=$total+$sales").
line 11: let: total+sales:expression recursion level exceeded (error token is "total+sales")
counter=0
sales=0
total=0
echo "enter sales price"
read sales
total=total+sales
while test $sales ; do... (5 Replies)
Discussion started by: Ccccc
5 Replies
8. Shell Programming and Scripting
Hi,
i want to use regular expression in a for loop like this.
for var in "/Mar/2010"
do
echo "Usage for the date $var"
-----and want to grep $var partten from a file--------
done
and it is not working.
I am new to shell scripting, any one has any idea how to do it. (5 Replies)
Discussion started by: tarakant
5 Replies
9. Shell Programming and Scripting
I'm writing a script to merge the xkcd webcomic tiles for comic 1110. So far, I have written about 100 lines, and instead of doing each quadrant of the image separately, I've decided to use functions to do this, repeating for every quadrant and using variables for each quadrant to make the function... (9 Replies)
Discussion started by: jbondhus
9 Replies
10. Red Hat
We have a RHEL 5.8 server at the production level and we have a Java application on this server. I know of the SSL certificate generation at the OS (RHEL) level but it is implemented on the Java application by our development team using the Java keytool. My doubt is that is the SSL generation can... (3 Replies)
Discussion started by: RHCE
3 Replies