Exiting a script

I have a script abc.sh. Its contents are as follows:

if ./try.sh will always return an error value (exit 1) this will work

./try.sh  && echo " done"  || exit 1

This will echo done, or exit depending on the return code of try.sh

What is abc.sh?

Your if statement doesn't look like it's using a proper test.

Do all the grep commands have to come up with a result in order for your condition to be true?

If the shell is not bash you cannot find errors in intervening pipes - the status is ALWAYS the last "pipe call" return code.

bash has pipestatus which lets you check return values from intermiediate pipes.

His code needs work, but his question is really about how to handle error exits in a parent process.

try.sh

if egrep "EUROPEi1|AMERICA1" filename; then echo "true"; else echo "false";exit 1; fi

abc.sh

./try.sh
if [ $? -eq 0 ]; then
echo "Done"
fi

cheers,
Devaraj Takhellambam

thanks devtak the code works fine.

d3vvnull im new to shell scripting so I am sure that there are some flaws in my code. what i want the code to do is check if any of the three values (umts, aws, mmds) exist then echo contine. what could be a better way to do it. and what am i doing wrong

mcnamara try.sh will not always retun an error. If it can find any of the three values (umts, mmds, aws) it should continue to perform other operations