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 ...
- 02-02-2012 #1Just Joined!
- Join Date
- Nov 2010
- Posts
- 23
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
- 02-02-2012 #2Linux 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:
armed with that, I could then do this, from a shell:Code:mysql -u db_user -e 'show databases'
and then in a Perl script, I could do something like:Code:/usr/bin/ssh $db_host "mysql -u db_user -e 'show databases'"
or if you wanted to capture the output to a variable:Code:system("/usr/bin/ssh $db_host \"mysql -e 'show databases'\"");
So check the documentation/man pages, etc. for sqlplus and see if anything like that is available.Code:my $out = `/usr/bin/ssh $db_host "mysql -e 'show databases'"`; print "$out\n";
- 02-02-2012 #3
I'm confused. Why wouldn't you want to use a module? That's exactly what they're designed for.
DBD::Oracle - search.cpan.orgDISTRO=Arch
Registered Linux User #388732
- 02-02-2012 #4Just Joined!
- Join Date
- Nov 2010
- Posts
- 23
- 02-03-2012 #5
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
- 02-08-2012 #6Just 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.


Reply With Quote
