Need help in perl script for oracle


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help in perl script for oracle
# 1  
Old 03-02-2011
Need help in perl script for oracle

Hi,

Code:
#!/usr/bin/perl

my @sid=`cat /etc/oratab|grep -v "^#"|grep -v "*"|grep -v "#"|cut -d: -f1 -s`;
my $log;
my $body="";
my $oraclesid="";
chomp($hostname);
foreach my $oraclesid (@SID){
        $body="";
        chomp($oraclesid);
        $dbname=print ($oraclesid);
        print ($dbname);
}

Actually we can get dbname from removing the last character of $oraclesid variable.plz help me in to get the dbname from oraclesid and assign it to dbname variable.

Moderator's Comments:
Mod Comment Please use code tags

Last edited by pludi; 03-03-2011 at 03:30 AM..
# 2  
Old 03-03-2011
Please use code tag for your code.
If I understood correctly your issue. then use
Code:
chop ($dbname);

after
Code:
chomp ($dbname);

# 3  
Old 03-04-2011
thanks for the help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help required for Oracle database shutdown script conversion from shell to perl

Please tell me how to convert below program from shell script to perl. Same commands need to use in shutdown, just need program help for startup. export ORACLE_BASE=/home/oracle1 lsnrctl start lndb1 sqlplus '/ as sysdba' startup; (2 Replies)
Discussion started by: learnbash
2 Replies

2. UNIX for Dummies Questions & Answers

I need perl script on cold backup in Oracle 10 g

Hi , I am new to Perl script.Can u please provide me perl scripts for the following: 1. Perl script on Cold backup in Oracle 10g 2.Perl script on Hot backup in Oracle 10g (0 Replies)
Discussion started by: Niharika Srivas
0 Replies

3. Programming

Help on a perl script to connect to oracle ASM as sysdba

I am novice to perl. Can someone guide me on the below query. We have an existing perl script which connects to database to check the disk group status which i wanted to retieve directly from ASM rather than database. This is because, a cluster has more than 4 databases running and a check on... (0 Replies)
Discussion started by: sai_rsk
0 Replies

4. Shell Programming and Scripting

Need to access Oracle DB with shell/perl script in Unix

Hi, We need to access Oracle DB with shell/perl script in Unix. Is Oracle client needed in Unix for this. I have seen threads which tell abt using SQL plus to access Oracle tables. Can we access DB without SQL PLus installation using scripts in UNix like we access DB using jar files in Java .... (1 Reply)
Discussion started by: justinacc
1 Replies

5. Shell Programming and Scripting

Perl connect to remote oracle db without local oracle installation

I want to use Perl to connect to a remote Oracle DB I have no oracle installation on my server (and dont plan on installing one) I am using solaris 9 on x86 server. Is this possible? I basically want to run some basic sql queries on the remote oracle db which I have access to using perl on my... (0 Replies)
Discussion started by: frustrated1
0 Replies

6. HP-UX

to create a oracle table in perl script

Hi all, I have to create table for each month inside a perl script. tablename_monthnameyear. megh_aug2008 for august 2008. megh_sep2008 for september 2008. just like the logfiles created on date basis. thanks megh (1 Reply)
Discussion started by: megh
1 Replies

7. Programming

perl dbi to oracle getting disconnect_all for oracle dbi help

hi i am trying to connect to an oracle database using dbi and i get this :: Driver has not implemented the disconnect_all method. at /opt/perl/lib/site_perl/5.8.0/sun4-solaris/DBI.pm line 575 END failed--call queue aborted. for all i know, the script was working earlier, but has... (1 Reply)
Discussion started by: poggendroff
1 Replies

8. Shell Programming and Scripting

Perl script variable passed to Oracle query

Hi All, I pass a Perl script variable, whch is passed to a query to be prepared. But the problem is I have special character like '&' in this variable which are handled in a special way by the Oracle query parser. How do I get over this? my $cust_name='A&B'; my $sql="Select cust_short_name... (1 Reply)
Discussion started by: rahulrathod
1 Replies

9. Shell Programming and Scripting

HOw to connect oracle using ksh and perl script

HI, So far i have been worked on sybase with perl and ksh scripts, i don't know how to connect using oralce, if any body could explain that is great. Thanks in advance. chendra (3 Replies)
Discussion started by: chendra.putta
3 Replies

10. UNIX for Dummies Questions & Answers

PERL - Oracle

Hi friends, I am new to Perl programming. I have a requirement, using perl I need to connect to Oracle DB and get some records ( on unix environment). I googled and found that we need to use DBD (Database Drivers), DBI (DataBase Interface) to connect to oracle. I tried using " sqlplus... (1 Reply)
Discussion started by: satguyz
1 Replies
Login or Register to Ask a Question