Calling binary from Perl prog and passing arguments

Calling binary from Perl prog and passing arguments

am 17.01.2008 15:26:19 von Vineet

Hi Experts,

I have sql interface which connects to oracle database. When I execute
sql, it connects to database and give prompt where user can type sql
statemets to be executed ... some thing like
$
$
$SQL;
SQL>
SQL>
SQL> select * from employee;
...............

I wanted to write wrapper script over SQL interface and read a file
having SQL statement and passed it to SQL interface.

Can you please guide me how to start writing this.
Thanks,
VS

Re: Calling binary from Perl prog and passing arguments

am 17.01.2008 18:55:55 von jurgenex

vineet wrote:
>I have sql interface which connects to oracle database. When I execute
>sql, it connects to database and give prompt where user can type sql
>statemets to be executed ... some thing like
>$
>$
>$SQL;
>SQL>
>SQL>
>SQL> select * from employee;
>..............
>
>I wanted to write wrapper script over SQL interface and read a file
>having SQL statement and passed it to SQL interface.

If you want the Perl program to interact with the external program's STDIO
then one of the "Expect" modules from CPAN is probably the best approach.

If you just want to pass parameters to the external program then system() or
qx// will do that already.

However, maybe you should investigate if accessing the database directly
from your Perl program is the best solution. Again, there are several
modules for database access on CPAN.

jue
>
>Can you please guide me how to start writing this.
>Thanks,
>VS

Re: Calling binary from Perl prog and passing arguments

am 17.01.2008 19:42:42 von Mark Clements

vineet wrote:
> Hi Experts,
>
> I have sql interface which connects to oracle database. When I execute
> sql, it connects to database and give prompt where user can type sql
> statemets to be executed ... some thing like
> $
> $
> $SQL;
> SQL>
> SQL>
> SQL> select * from employee;
> ..............
>
> I wanted to write wrapper script over SQL interface and read a file
> having SQL statement and passed it to SQL interface.
>
> Can you please guide me how to start writing this.
> Thanks,
> VS
would

sqlplus < statement.sql

not do it, where statement.sql is the file containing the SQL statements?

Re: Calling binary from Perl prog and passing arguments

am 17.01.2008 19:48:32 von Jim Gibson

In article
<4f375943-9bfe-475b-8a1f-a48f8c42b5b6@j20g2000hsi.googlegroups.com>,
vineet wrote:

> Hi Experts,
>
> I have sql interface which connects to oracle database. When I execute
> sql, it connects to database and give prompt where user can type sql
> statemets to be executed ... some thing like
> $
> $
> $SQL;
> SQL>
> SQL>
> SQL> select * from employee;
> ..............
>
> I wanted to write wrapper script over SQL interface and read a file
> having SQL statement and passed it to SQL interface.
>
> Can you please guide me how to start writing this.

Perl contributors have written Perl modules to access databases in a
database-independent manner, including Oracle. The module DBI.pm
presents a database-independent interface to many databases, with a
database-specific DBD module providing the actual interface
(DBD::Oracle in your case). If you have a long-term interest in
manipulating databases, this is the recommended approach.

See, for example, the Perl FAQ entry displayed with 'perldoc -q
database', and look on CPAN () for DBI,
DBD::Oracle, and many other Oracle-related modules.

You can start an external process and pipe data to its standard input
by using the Perl open function with an '|-' argument. This might work
for commanding Oracle's sql utility (I haven't tried it).

See 'perldoc -f open' for details.

--
Jim Gibson

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Re: Calling binary from Perl prog and passing arguments

am 01.02.2008 19:33:25 von Vineet

Thanks group for your valuable time and advise.
I was looking some thing like expect
Vineet