- 论坛徽章:
- 0
|
各位大神:
我写了个程序读取sql文件然后用system插入到数据库中,代码如下
foreach my $sqlfile (@sqlfiles) {
#1 skip directory
next if (-d $sqlfile);
#2 parse schema from file name
my @fldsofname = split "_",$sqlfile;
my $idbschema = $fldsofname[0];
my $sqldatafile = $MODETLINFO::SYNCSQLRCV . "/" . $sqlfile;
my $icmd = "mysql -u$dbusr -p$dbpwd -h $dbhost $idbschema < $sqldatafile";
system($icmd);
}
我想打印报错的日志,怎么样才能捕捉到错误的日志打印出来呢,比如说一张表已经存在,或者插入错误等等。。
现在只能在unix窗口提示
ERROR 1050 (42S01) at line 1: Table 'cde_spvs_ppdm' already exists
我想把这句话输出到文件里 |
|