Sponsored Content
Top Forums Shell Programming and Scripting Execute immediate in perl script Post 302799243 by lovelysethii on Friday 26th of April 2013 05:04:16 AM
Old 04-26-2013
here is the portion of code where we are referencing a procedure through a package

Code:
 $user=$ENV{CREDIT_LOAD};
    $password=$ENV{CREDIT_PSWD};


        $dbname=$ENV{ORACLE_SID} || mail_abort("ar_portfolio.pl","Environment not setup! no SID");
    $dbh = DBI->connect( 'dbi:Oracle:' . $dbname,$user,$password)  ||
                mail_abort("ar_portfolio.pl","Database connection not made $DBI::errstr");

        $dbh->{PrintError} =0;
        $dbh->{RaiseError} =0;
        $dbh->{AutoCommit} =1;


        IdxCntrl->init($dbname,$user,$password);

        TrxLog::begin("AR Portfolio");

        set_color_pct();
        print "60 green: $pct60_green_limit\n";
        print "60 yellow: $pct60_yellow_limit\n";
        print "120 green: $pct120_green_limit\n";
        print "120 yellow: $pct120_yellow_limit\n";

        $sth = $dbh->prepare("BEGIN ar_portfolio.insert_into_ar_new; END;")or mail_abort("ar_portfolio.pl", "cant prepare: $s
ql\n");


Last edited by Corona688; 04-26-2013 at 12:57 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

execute a ksh script from perl script!

Hi, I have used exec ("/bin/ksh -c /path/file.ksh arg1"); to execute the file.ksh script from a test.pl script. But it doesnt work.. can anyone tell me what exactly the systax should be?... i have tried system("/path/file.ksh arg1"); too....still no luck... quick replies are highly appreciated (1 Reply)
Discussion started by: meghana
1 Replies

2. UNIX for Dummies Questions & Answers

a cron job needs a perl script to execute

Hello evreyone, this is my first post, and to say i'm new to this is an understatement. I know very little about perl scripts and hope some one can help me. i'm looking to get a script that a cron job can execute. what the script needs to to is 1) connect to a mysql database 2) go to a... (2 Replies)
Discussion started by: Exader
2 Replies

3. Shell Programming and Scripting

[Solved] how Execute a Perl Script from any location on the machine

hi guys, i have a query, i wrote a perl script that will collect cpu statistics Scripts/myScripts/ cpu.pl i want to make this file so that i can run it from any location on any drive, without giving the path explicitly. like $/home/ravi/perl cpu.pl i tried this... (8 Replies)
Discussion started by: niteesh_!7
8 Replies

4. Shell Programming and Scripting

Perl Script to execute todays date.

Hi Folks, I have created a script last month to retrive files thru FTP and cronjob was running fine till yesterday. But the naming convention of the daily file is Filename_<date>.xml where date is YYYYMMDD. But today i have received file name as Filename_20110232.xml :( Part of my Perl... (4 Replies)
Discussion started by: Sendhil.Kumaran
4 Replies

5. Shell Programming and Scripting

Cannot execute Unix command in a simple perl script

Am trying to lean perl scripting in Unix OS to automate my tasks. Please find the below perl script i have tried #!/usr/bin/perl -w print "Please Enter the VG name to be checked:"; $A = <>; print "Please Enter the free size to be checked in GB:"; $B = <>; $vgcheck = `vgdisplay... (7 Replies)
Discussion started by: jayachandran87
7 Replies

6. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

7. Shell Programming and Scripting

perl script to check read/write/execute permission for 'others'

I want to check access rights permissions not for 'user', not for 'group', but for 'others'. I want to do it by system command in which i want to use 'ls -l' and 'awk' command. I have written the following program : #!/usr/bin/local/perl #include <stdlib.h> system ("ls -l | awk... (1 Reply)
Discussion started by: shubhamsachdeva
1 Replies

8. Shell Programming and Scripting

[perl] execute remotely script

Hello Can some help with write part of perl script I need something like this in perl SSH="/bin/ssh -o BatchMode=yes -o" USER="test" SRV="server" SCRIPT_TO_EXEC="/tmp/test.sh" -> shell script OUT=/tmp/out.file ${SSH} -l ${USER} ${SRV} 'sudo /usr/bin/ksh -s' < ${SCRIPT_TO_EXEC} >> ${OUT}... (1 Reply)
Discussion started by: vikus
1 Replies

9. Programming

PERL: In a perl-scripttTrying to execute another perl-script that SETS SOME VARIABLES !

I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open()) I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies

10. UNIX for Beginners Questions & Answers

Perl script with lock to execute only once in a day

Hi, I am new to perl and have a script to which i want to ensure that no matter how many ever times i execute the script it should execute only once per day. Cronjob is not a safe method as I want to built in capability inside the script. (1 Reply)
Discussion started by: ctrld
1 Replies
Log::Handler::Output::DBI(3pm)				User Contributed Perl Documentation			    Log::Handler::Output::DBI(3pm)

NAME
Log::Handler::Output::DBI - Log messages to a database. SYNOPSIS
use Log::Handler::Output::DBI; my $db = Log::Handler::Output::DBI->new( # database source database => "database", driver => "mysql", host => "127.0.0.1", port => 3306, # or with "dbname" instead of "database" dbname => "database", driver => "Pg", host => "127.0.0.1", port => 5432, # or with data_source data_source => "dbi:mysql:database=database;host=127.0.0.1;port=3306", # Username and password user => "user", password => "password", # debugging debug => 1, # table, columns and values (as string) table => "messages", columns => "level ctime cdate pid hostname progname message", values => "%level %time %date %pid %hostname %progname %message", # table, columns and values (as array reference) table => "messages", columns => [ qw/level ctime cdate pid hostname progname message/ ], values => [ qw/%level %time %date %pid %hostname %progname %message/ ], # table, columns and values (your own statement) statement => "insert into messages (level,ctime,cdate,pid,hostname,progname,message) values (?,?,?,?,?,?,?)", values => [ qw/%level %time %date %pid %hostname %progname %message/ ], # if you like persistent connections and want to re-connect persistent => 1, ); my %message = ( level => "ERROR", time => "10:12:13", date => "1999-12-12", pid => $$, hostname => "localhost", progname => $0, message => "an error here" ); $db->log(\%message); DESCRIPTION
With this output you can insert messages into a database table. METHODS
new() Call "new()" to create a new Log::Handler::Output::DBI object. The following options are possible: data_source Set the dsn (data source name). You can use this parameter instead of "database", "driver", "host" and "port". database or dbname Pass the database name. driver Pass the database driver. host Pass the hostname where the database is running. port Pass the port where the database is listened. user Pass the database user for the connect. password Pass the users password. table and columns With this options you can pass the table name for the insert and the columns. You can pass the columns as string or as array. Example: # the table name table => "messages", # columns as string columns => "level, ctime, cdate, pid, hostname, progname, message", # columns as array columns => [ qw/level ctime cdate pid hostname progname message/ ], The statement would created as follows insert into message (level, ctime, cdate, pid, hostname, progname, mtime, message) values (?,?,?,?,?,?,?) statement With this option you can pass your own statement if you don't want to you the options "table" and "columns". statement => "insert into message (level, ctime, cdate, pid, hostname, progname, mtime, message)" ." values (?,?,?,?,?,?,?)" values With this option you have to set the values for the insert. values => "%level, %time, %date, %pid, %hostname, %progname, %message", # or values => [ qw/%level %time %date %pid %hostname %progname %message/ ], The placeholders are identical with the pattern names that you have to pass with the option "message_pattern" from Log::Handler. %L level %T time %D date %P pid %H hostname %N newline %C caller %p package %f filename %l line %s subroutine %S progname %r runtime %t mtime %m message Take a look to the documentation of Log::Handler for all possible patterns. persistent With this option you can enable or disable a persistent database connection and re-connect if the connection was lost. This option is set to 1 on default. dbi_params This option is useful if you want to pass arguments to DBI. The default is set to { PrintError => 0, AutoCommit => 1 } "PrintError" is deactivated because this would print error messages as warnings to STDERR. You can pass your own arguments - and overwrite it - with dbi_params => { PrintError => 1, AutoCommit => 0 } debug With this option it's possible to enable debugging. The information can be intercepted with $SIG{__WARN__}. log() Log a message to the database. my $db = Log::Handler::Output::DBI->new( database => "database", driver => "mysql", user => "user", password => "password", host => "127.0.0.1", port => 3306, table => "messages", columns => [ qw/level ctime message/ ], values => [ qw/%level %time %message/ ], persistent => 1, ); $db->log( message => "your message", level => "INFO", time => "2008-10-10 10:12:23", ); Or you can connect to the database yourself. You should notice that if the database connection lost then the logger can't re-connect to the database and would return an error. Use "dbi_handle" at your own risk. my $dbh = DBI->connect(...); my $db = Log::Handler::Output::DBI->new( dbi_handle => $dbh, table => "messages", columns => [ qw/level ctime message/ ], values => [ qw/%level %time %message/ ], ); connect() Connect to the database. disconnect() Disconnect from the database. validate() Validate a configuration. reload() Reload with a new configuration. errstr() This function returns the last error message. PREREQUISITES
Carp Params::Validate DBI your DBI driver you want to use EXPORTS
No exports. REPORT BUGS
Please report all bugs to <jschulz.cpan(at)bloonix.de>. If you send me a mail then add Log::Handler into the subject. AUTHOR
Jonny Schulz <jschulz.cpan(at)bloonix.de>. COPYRIGHT
Copyright (C) 2007-2009 by Jonny Schulz. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-11-21 Log::Handler::Output::DBI(3pm)
All times are GMT -4. The time now is 10:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy