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 ?
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 ?