Results 1 to 3 of 3
ok, so this is probably not a beginner's question, but I cannot find another forum topic this would fit in.
I currently have a bash script which calls sqlplus to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-13-2012 #1Just Joined!
- Join Date
- Jun 2012
- Posts
- 11
sqlplus within bash script not working properly when called remotely
ok, so this is probably not a beginner's question, but I cannot find another forum topic this would fit in.
I currently have a bash script which calls sqlplus to do a simple query and stores it into a variable.
I use this query to grep for processes that should be turned on in my system and then run some commands to check to make sure the processes are actually running. (I can't change the way the system works, it just works this way and I am writing scripts to do checks to make sure its running)Code:variable=`sqlplus user/password<<-EOF select stuff1,stuff2,stuff3 from table1; EOF `
Anyway, when my script is run from my local machine, it works perfectly. The problem is when I run it remotely from another machine. I now have to run it remotely because we have multiple machines that we need to be able to check all at once without having to manually log into each machine and run the script. Also, there is one DB machine with one schema that all our systems connect to. They have it so that you can log into SQLPLUS directly on our machines without having to log into the oracle server directly.
When I run it this way, the script runs, the SQLPLUS portion even runs, but instead of returning the proper query results, it returns "no rows selected".Code:ssh -x user@machine 'myScript.sh'
So i am confused as to why its connecting to SQLPLUS properly, but then not executing the query correctly or at all. I was under the assumption that when I run the script remotely like that, the script actually runs locally on that other machine.
I already have the environment set up properly and have double checked.
I guess the thing that confuses me most is the fact it is properly connecting to the database, but the query isn't executing properly. I assume it is maybe some setting or option in ssh or the way I am calling the script or something, but I have tried everything I know of and have run out of options.
thanks in advance,
Jeremy
- 10-15-2012 #2Linux Newbie
- Join Date
- Aug 2006
- Posts
- 115
Because you're running remotely, it could be a hostname or a user@hostname issue. Did you check that ?
- 10-15-2012 #3Just Joined!
- Join Date
- Jun 2012
- Posts
- 11
I figured out the issue a couple hours ago. it was an environment issue. They switched our DB machines and the .ssh/environment file had the old ORACLE_SID in it. I updated my .ssh/environment file to reflect the proper SID and now everything works.
thanks for the response.


Reply With Quote
