非稅代收系統主機建立對賬檔案的perl指令碼

2021-08-25 02:59:59 字數 2116 閱讀 3578

非稅代收系統主機每天晚上需要自動生成text格式的對賬文字,因此編寫了如下perl指令碼,加入crontab,讓它每天自動執行。

#!/usr/bin/perl

# createduizhangtext.pl

use strict;

use warnings;

use dbi;

#use text::csv_xs;

my $server='localhost';

my $username='dsywfs';

my $password='*******';

my $dbname='dsywfs';

my $dsn = "dbi:mysql:host=$server;database=$dbname";

my %conn_attrs = (printerror => 0, raiseerror => 1, autocommit => 1);

my $yhbm='440900015';

#@ _connect_

my $dbh = dbi->connect ($dsn, $username, $password, \%conn_attrs)

or die "connection error: "

. "$dbi::errstr ($dbi::err/$dbi::state)\n";

#@ _connect_

my ($year,$mon,$day)=(localtime)[5,4,3];

$year+=1900;

$mon+=1;

#$day-=1; //by laihanfen

my $jfdate=sprintf("%04u-%02u-%02u",$year,$mon,$day);

my $dzdate=sprintf("%04u%02u%02u",$year,$mon,$day);

my $filename = '/tmp/yhsc/yhsk' . $yhbm . $dzdate . '01.txt';

#$jfdate = '2010-01-05';

#@ _count_zbs_

my $sth = $dbh->prepare ("select count(*) as `zbs` from `skmx` where `jfdate` like '$jfdate%' and `dzlog`='0' and `czlog`='0'");

$sth->execute ();

my $zbs = $sth->fetchrow_array ();

#my $zbs = $bs[0];

$sth->finish ();

#@ _count_zbs_

#@ _count_fkje_

$sth = $dbh->prepare ("select sum(`fkje`) as `fkje` from `skmx` where `jfdate` like '$jfdate%' and `dzlog`='0' and `czlog`='0'");

$sth->execute ();

my $fkje = $sth->fetchrow_array ();

#my $fkje = $je[0];

$sth->finish ();

#@ _count_fkje_

#@ _count_jsje_

$sth = $dbh->prepare ("select sum(`jsje`) as `jsje` from `skmx` where `jfdate` like '$jfdate%' and `dzlog`='0' and `czlog`='0' and `jsje`>0");

$sth->execute ();

my $jsje = $sth->fetchrow_array ();

#my $jsje = $js[0];

$sth->finish ();

#@ _count_jsje_

注:在perl中可以使用map來轉化任何undel(null)值:

// 摘自《mysql cookbook中文版》(第二版)115頁

while (my @var = $sth->fetchrow_array())

@var;

}

rootfs檔案系統的建立

首先,定義兩個file system type結構 fs ramfs inode.c line284 static struct file system type ramfs fs type static struct file system type rootfs fs type ramfs fs...

sysfs系統 檔案和目錄的建立

sysfs是linux的特殊檔案系統,這個檔案系統主要作用是在使用者態展示裝置的資訊。linux計算機系統中,可以在根目錄下面找到sys目錄,這個目錄就是利用sysfs檔案系統進行建立的。開啟sys目錄,可以看到裝置的分類顯示,如下所示 yxf yxf pc sys ls block bus cla...

linux檔案系統omfs的普通檔案建立和刪除

omfs的普通檔案的建立刪除與目錄建立刪除的動作非常類似,下面僅僅描述一下 在omfs create處下斷點 breakpoint 3,omfs create dir 0xdde13c20,dentry 0xdf6f6440,mode 33188,nd 0xddbe1eb8 at fs omfs d...