Find the answer to your Linux question:
Results 1 to 6 of 6
Hi All' I need a execute oracle command on remote db server using perl and I try with following but it not work. Can any one Suggest way to do ...
  1. #1
    Just Joined!
    Join Date
    Nov 2010
    Posts
    23

    Lightbulb use Oracle commands inside perl script with SSH

    Hi All'

    I need a execute oracle command on remote db server using perl and I try with following but it not work. Can any one Suggest way to do this without using DBI or any module.


    Code:
    my $memp = qx{ssh -o stricthostkeychecking=no  $db_hosts "sqlplus -s $db_string<<EOF
                    show parameter memory;
                    exit 
                    EOF"};

    Thanks

  2. #2
    Linux Guru
    Join Date
    May 2011
    Posts
    1,843
    I'm more of a MySQL person, so I'm not familiar with sqlplus. but I know that with mysql there is a way to pass a command to a MySQL instance and then exit (using the -e parameter). e.g., this command will show all databases on my MySQL server:

    Code:
    mysql -u db_user -e 'show databases'
    armed with that, I could then do this, from a shell:

    Code:
    /usr/bin/ssh $db_host "mysql -u db_user -e 'show databases'"
    and then in a Perl script, I could do something like:

    Code:
    system("/usr/bin/ssh $db_host \"mysql -e 'show databases'\"");
    or if you wanted to capture the output to a variable:
    Code:
    my $out = `/usr/bin/ssh $db_host "mysql -e 'show databases'"`;
    print "$out\n";
    So check the documentation/man pages, etc. for sqlplus and see if anything like that is available.

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    I'm confused. Why wouldn't you want to use a module? That's exactly what they're designed for.
    DBD::Oracle - search.cpan.org
    DISTRO=Arch
    Registered Linux User #388732

  4. #4
    Just Joined!
    Join Date
    Nov 2010
    Posts
    23
    Thank you very much for quick reply.

    Quote Originally Posted by Cabhan View Post
    I'm confused. Why wouldn't you want to use a module? That's exactly what they're designed for.
    DBD::Oracle - search.cpan.org
    I need to run this script on client side.so I can't depend on any modules.

  5. #5
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    I guess I would still ask why you can't. Presumably your script will be installed somehow on the client's machine: why can't the module be as well? Or why not just distribute them together?

    Although sqlplus can probably get so far as "Execute a command", it's going to be very difficult to parse its output (hell, sqlplus is hard enough to use when you're using it the way it was intended, let alone using it a different way), or to do anything within the context of a transaction, or anything like this.
    DISTRO=Arch
    Registered Linux User #388732

  6. #6
    Just Joined!
    Join Date
    Nov 2010
    Posts
    23
    Thanks Cabhan;


    Finally I realized that without module can't be survive..,so can you please explain how can I used this module with my script.I mean How I create one package with module to send client.

Posting Permissions

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