KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

returning a value from SQLPLUS does not work

 
Post new topic   Reply to topic    KS-Soft Forum Index -> RMA for UNIX
View previous topic :: View next topic  
Author Message
tom



Joined: 23 Oct 2007
Posts: 2

PostPosted: Tue Oct 23, 2007 3:59 pm    Post subject: returning a value from SQLPLUS does not work Reply with quote

Hello,
I have written a small script to get the state of an oracle DB in HM.
The Script should return the state of the Oracle DB

If I run the script "test3.sh" within putty as user root, everthing worksfine and I get the result value.
If I call the script from Hostmonitor I get no value for val. The RMA is running with root rights.

I'm not very familiar with scripting on/and Linux. Probably it is more a problem of my scripting knowledge than a problem of HM.

Perhaps someone has an idea!
Thanks in advance.

Thomas

#!/bin/sh
VAL="Error"
VAL=`./home/oracle/epeppdm/test3.sh`
if [ "$VAL" == "OPEN" ]; then
echo ScriptRes:Ok:$VAL
else
echo ScriptRes:Bad:$VAL
fi

---------- test3.sh ----------
#!/bin/sh
instance='$Instance'
VAL="ERROR"
VAL=`/opt/oracle/product/10.2.0/bin/sqlplus -s system/manager <<END
set pagesize 0 feedback off verify off heading off echo off
select status from v$instance
exit;
END`
echo $VAL
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Wed Oct 24, 2007 5:23 am    Post subject: Re: returning a value from SQLPLUS does not work Reply with quote

tom wrote:
If I run the script "test3.sh" within putty as user root, everthing worksfine and I get the result value.
If I call the script from Hostmonitor I get no value for val. The RMA is running with root rights.
Do you mean, you have tested it using "Lets try" tab of the "Script Manager" or you have setup a particular test? What exact error do you see in "Reply" field of the test? Have you selected appropriate agent from the "Test by" dropdown in "Test Properties" window?

Regards,
Max
Back to top
View user's profile Send private message Send e-mail Visit poster's website
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Wed Oct 24, 2007 8:33 am    Post subject: Re: returning a value from SQLPLUS does not work Reply with quote

tom wrote:
#!/bin/sh
VAL="Error"
VAL=`./home/oracle/epeppdm/test3.sh`
if [ "$VAL" == "OPEN" ]; then
echo ScriptRes:Ok:$VAL
else
echo ScriptRes:Bad:$VAL
fi
I think, script should be like the following:
Code:
#!/bin/sh
VAL="Error"
VAL=`/home/oracle/epeppdm/test3.sh`;
if [ $VAL == "OPEN" ] then
  echo ScriptRes:Ok:$VAL
else
  echo ScriptRes:Bad:$VAL
fi


BTW. You may copy the foregoing script into some .sh file and try to execute it on your system to check it works.

Regards,
Max
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tom



Joined: 23 Oct 2007
Posts: 2

PostPosted: Wed Oct 24, 2007 10:40 am    Post subject: Reply with quote

Hello again...

thanks for your fast reply

We solved the problem .... the solution is ... that the RMA needs oracle user rights. We got no results from the RMA, because the RMA has not the rights to run sqlplus....
(...I have no idea, why the user root is allowed to start sqlplus in putty...)

Therfore we got no result in HM

Here know is the correct script wihich works fine..... if the RMA runs as user oracle ...

By the way ... HM is a great tool.

Thanks

Thomas

#!/bin/sh
instance='$Instance'
VAL="ERROR"
VAL=`sqlplus -s / as sysdba <<END
set pagesize 0 feedback off verify off heading off echo off
select status from v$instance;
exit;
END`
if [ "$VAL" == "OPEN" -o "$VAL" == "MOUNTED" ]; then
echo ScriptRes:Ok:$VAL
else
echo ScriptRes:Bad:$VAL
fi
Back to top
View user's profile Send private message
KS-Soft Europe



Joined: 16 May 2006
Posts: 2832

PostPosted: Wed Oct 24, 2007 10:52 am    Post subject: Reply with quote

tom wrote:
We solved the problem .... the solution is ... that the RMA needs oracle user rights. We got no results from the RMA, because the RMA has not the rights to run sqlplus....
Glad to hear that.
tom wrote:
Here know is the correct script wihich works fine..... if the RMA runs as user oracle ...
Thank you. Script looks fine.

tom wrote:
By the way ... HM is a great tool.
Thank you. We appreciate your feedback.

Regards,
Max
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> RMA for UNIX All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index