Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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.

    variable=`sqlplus user/password<<-EOF
                  select stuff1,stuff2,stuff3 from table1;
    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)

    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.

    ssh -x user@machine ''
    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".

    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,


  2. #2
    Because you're running remotely, it could be a hostname or a user@hostname issue. Did you check that ?

  3. #3
    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.

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts