Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some trouble with su in script

Status
Not open for further replies.

Ogzilal

MIS
Oct 9, 2003
280
FR
Hello world,

I have some confusion with su command in a script.
Im loggin as root and execute the following command :

su - oracle <<-!
grep 'some text' /etc/oratab
if [ $? -eq 0 ]
then
print "some text found" in /etc/oratab
else
print "some text not found" in /etc/oratab
fi
!
some text found in /etc/oratab

but my /etc/oratab does not contain the pattern "some text"

Another variant is

su - oracle <<-!
grep 'some text' /etc/oratab
print "exit status of grep = $? "
!
exit status of grep = 0

but my /etc/oratab still does not contain the pattern "some text"

Question : How can I get the right exit status of grep command within the su ?
 
-eq is to compare strings, try using the =, the integer comparator (is that a word?).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top