1834165 Members
1975 Online
110064 Solutions
New Discussion

Perl script help

 
SOLVED
Go to solution
Kris_5
Occasional Advisor

Perl script help

Hi All,

I am trying to write a small perl script which runs a small sql using sqlplus. Perl code looks like this.

open(p_scode,"|/db01/app2/oracle/product/8.1.7/bin/sqlplus -s /");

print p_scode<spool $prj_sty_lst_fl
select lower(a.project_code)||...
...
...
close p_scode;

When I execute the perl script, the sql output is written in spool file as well as shown on to screen (which I don't want). How do I suppress the output to screen.

Thanks in adv.

Krish
5 REPLIES 5
K.Vijayaragavan.
Respected Contributor

Re: Perl script help

I think it is beacuse of STDOUT file handle used by the "print " statement in this script.
"Let us fine tune our knowledge together"
Ollie R
Respected Contributor

Re: Perl script help

Hi Krish,

I don't know your level of ORACLE knowledge so please excuse me if you find any of this a little condescending!

I think it's because you need to turn echoing off within the ORACLE script.

Try adding a line such as:
set echo off
before your spool definition and see if that makes any difference.

You can also use:
set heading off
set feedback off
and several others depending on what you need returning.

BTW, if you're expecting the "-s" options to run silent, I believe it's a capital "S".

Ollie.
To err is human but to not award points is unforgivable
Kris_5
Occasional Advisor

Re: Perl script help

Hi Ollie,

In the sql script, I did used echo off, but still the output is sent to screen. If it is a shell script, I could easily send the output to /dev/null, but in perl I have no idea on how to send this to null device. This is my first perl script. TIA

set termout off
set trimspool on
set pagesize 0
set feedback off
set echo off
set verify off
select lower(a.project_code)||...
...
...

Kris
Mark Landin
Valued Contributor

Re: Perl script help

I don't know Oracle, so I don't think I can help you directly here. BUT, when I have Perl questions, I often go to www.perlmonks.org, a fantastic online Perl community populated by some VERY wizardly people, including a couple of the authors of the O'Reilly camel book.

I'm not denigrating these forums here at all ... Perl Monks is another resource for Perl-specific issues, though.
Rodney Hills
Honored Contributor
Solution

Re: Perl script help

Change the STDOUT and STDERR on the sqlplus command-

open(p_scode,"|/db01/app2/oracle/product/8.1.7/bin/sqlplus -s / >/dev/null 2>&1");

This way any output generated by sqlplus will be sent to the bit bucket.

HTH

-- Rod Hills
There be dragons...