The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cat and grep not working jphess UNIX for Advanced & Expert Users 3 09-08-2008 01:51 PM
grep -r isn't working harishmitty SUN Solaris 8 09-03-2008 11:44 PM
Grep not working - special characters?? gugs Shell Programming and Scripting 3 07-31-2008 08:22 AM
grep -A switch not working correctly with -m zer0 UNIX for Dummies Questions & Answers 2 06-19-2008 03:26 AM
grep is not working, please find out the problem kittusri9 Shell Programming and Scripting 3 05-07-2008 07:32 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-24-2008
Registered User
 

Join Date: Jul 2006
Posts: 66
grep not working

This condition is not able to grep , can any one tell what's wrong with this part.

I am able to see from unix command but not with host script.

Code:
echo "Checking for Loader Status " >>  $REPFILE
    if test $? = 0
    then
        echo "Successful termination of SQL*Loader "$LOADER1  >> $REPFILE
        grep "successfully loaded." $LOGDIR/$LOADER1.log >> $REPFILE
        grep "not loaded due to data errors" $LOGDIR/$LOADER1.log >> $REPFILE
        grep "not loaded because all fields were null" $LOGDIR/$LOADER1.log >> $REPFILE
    else 
	echo "Loader has some problems " >>  $REPFILE       
	PROBLEMS=1
    fi
Reply With Quote
Forum Sponsor
  #2  
Old 09-24-2008
vidyadhar85's Avatar
The Tutor
 

Join Date: Jun 2008
Location: INDIA
Posts: 549
its because its getting failed in
Quote:
if statement only
run script as
Quote:
sh -x scriptname
change it to
Quote:
if [ $? == 0 ]
or if [ $? -eq 0 ]
Reply With Quote
  #3  
Old 09-24-2008
Registered User
 

Join Date: Jul 2006
Posts: 66
No luck..
I am trying to called sqlloader from unix. SQLlaoder execution went fine, but could not able to grep.

Is some problem with unix version. Same code works fine in solaries, this time working in HP-UX
Reply With Quote
  #4  
Old 09-24-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
No, the if is correct. If you use test instead of [ you don't need the closing square bracket. Single equals signs are permitted (and I believe more portable than double equals signs).

It's not clear from which command you want the exit code in $? -- from the echo, or from some previous command? The way I read it you will always have the exit code from the echo, which will always be zero; is that not what you are seeing?

In what way are the greps failing -- not running, or not returning what you expect? Do you get an error message?
Reply With Quote
  #5  
Old 09-24-2008
vidyadhar85's Avatar
The Tutor
 

Join Date: Jun 2008
Location: INDIA
Posts: 549
Quote:
No, the if is correct. If you use test you don't need the closing square bracket
ya era sorry my mistake..
Reply With Quote
  #6  
Old 09-26-2008
Registered User
 

Join Date: Mar 2008
Posts: 107
$? applies to the last command executed. In this case an "echo" rather than the main command.
You'll need to save the exit status from the main command immediately after execution.

sqlcommand_we_want_to_check ; ERROR=$?
.
# Other commands
.
if [ ${ERROR} = 0 ]

... etc.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0