charithd has asked for the wisdom of the Perl Monks concerning the following question:

Hi All' I need a execute oracle command on remote db server using perl and I try with following but it not works. Can any one Suggest way to do this without using DBI or any module.If I must use module please explain way to use module as portable package.(I need to send this module with script to client)
my $memp = qx{ssh -o stricthostkeychecking=no $db_hosts "sqlplus -s $ +db_string<<EOF show parameter memory; exit EOF"};
Thanks

Replies are listed 'Best First'.
Re: Connect to Remote oracle DB
by GrandFather (Saint) on Feb 13, 2012 at 09:45 UTC

    In what fashion does it not work? Do you get errors? Are there errors in the logs on the host? Do you know through some other means that you can connect to the database from the client?

    True laziness is hard work
      It's says "bash: sqlplus: command not found" When I used "`" backtick
      my $memp = qx{ssh -o stricthostkeychecking=no $db_hosts `sqlplus -s $ +db_string<<EOF show parameter memory; exit EOF`};
      it says " bash: ERROR:: command not found bash: change: command not found "

        my first guess is you don't have the sqlplus binary in your PATH on the target server.

        have you tried running it from the command line?

        what do you get when you run:

        ssh -o StrictHostKeyChecking=no <your_db_host> sqlplus <your_connect_s +tring>
        on your *nix shell?

Re: Connect to Remote oracle DB
by Eliya (Vicar) on Feb 13, 2012 at 10:17 UTC

    For one, the terminating EOF should be at the beginning of a line (like Perl, the shell does not allow leading whitespace here).

Re: Connect to Remote oracle DB
by kielstirling (Scribe) on Feb 13, 2012 at 09:51 UTC
    Hi,

    Do you have private and public keys set up ? How are you logging to sqlplus? You are not supplying a username and passwd?

Re: Connect to Remote oracle DB
by Anonymous Monk on Feb 13, 2012 at 17:23 UTC

    What is in your $db_string? I'm concerned that the ID / password / ORACLE_SID string may be malformed. That's particularly true if you aren't used to accessing remote Oracle databases.

    Posting it, with password and ORACLE_SID replaced, would help.

      Thanks you very much for you all to great quick replies. I have oracle client installed in my host and I already have set TNS record and through that I can connect to my remote db. But I just wanted to ssh remote db host and execute sqlplus from that point.because I can't get set oracle client and tns on every host that I going to run my script.same as DBI module. if there any way to use this module without installing,I mean as portable module so I can send module and script as one package so no dependencies. Thanks again.