Hello Kennethk,ercparker and gulden,
Thanq very much for the quick reply.
Sorry I didnt post you the entire code before.
Here I posted the entire code.
Gulden I tried with FindBin also but the problem is
when we use Findbin we cant use $0,(where I need filename along with the path)
So when I am printing the $path I am getting the path in the console.
But while I insert it to the "DBtst" it is not giving the path like this
D:\Portal\Types\Program\Script_types.pl
instead giving the path as D:PortalTypesProgramScript_types.pl
Please find a solution to my problem
Thanku
use Config::Simple;
use warnings;
$cfg = new Config::Simple();
$cfg->read('../config/Amis_a.conf');
use Cwd qw(abs_path);
$dbh = DBI->connect('dbi:mysql:' . $DB_schema . ';' . $DB_server , $DB
+_login , $DB_password)
or die "Connection Error: $DBI::errstr\n";
my $status;
my $message;
open(MYFILE, "<err_output_types.txt"); # open for input
flock(MYFILE, LOCK_EX);
seek(MYFILE, 0, SEEK_SET);
my(@lines) = <MYFILE>; # read file into list
my $size = @lines;
print "Size $size\n";
foreach $line (@lines) {
print "$line";
}
close(MYFILE);
if ($size !=0)
{
$status=ERROR;
$message="Program failed due to Errors";
}
else
{
$status=OK;
$message="Program ended successfully";
}
my $path = abs_path($0);
print "$path\n";
print $message;
my $sth = $dbh->prepare(<<SQL);
INSERT IGNORE INTO DBtst.logs(Status,Message,Origin)VALUES('$status','
+$message','$path')
;
SQL
$sth->execute() or die $DBI::errstr;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.