perl to get remote file property is simple,but it spends me lots of time to findout windows driver syntax .
use strict;
use warnings;
use File::Copy;
my $remote_file = "\\\\192.168.1.1\\c\$\\temp.log";
my ($mtime) = (stat $remote_file)[9];
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($mtime);
$year+=1900;
$mon +=1;
print "$year/$mon/$mday $hour:$min:$sec";
copy($remote_file, "C:\\Temp");
Feb 25, 2009
perl get remote file property and copy to local - for windows
Feb 24, 2009
perl ado connection for sql server , oracle, MySQL by Win32::OLE
A easy way to connect database server and get data by using perl Win32::OLE.
The connection string is same with asp or vbscript.
use Win32::OLE;
#for sqlserver with user/password
#my $ConnStr="driver={SQL Server};server=
#for oracle , must install oracle client first to get connction str
#my $ConnStr="driver={Microsoft ODBC for Oracle};server=
#for sqlserver with Trusted_Connection
my $ConnStr="driver={SQL Server};server=
#For MySQL
my $connCMDBstr="DRIVER={MySQL ODBC 3.51 Driver};SERVER=192.168.2.1; PORT=3306;DATABASE=Test; USER=root; PASSWORD=; OPTION=3;";
my $Conn = Win32::OLE-> new('ADODB.Connection');
$Conn-> Open($ConnStr);
my $err = Win32::OLE::LastError();
if (not $err eq "0")
{
print"FATAL: no connection, OLE error 0x%08x: $err\n";
exit;
}
my $Statement = "select * from sysdatabases";
if(! ($RS = $Conn->Execute($Statement)))
{
print Win32::OLE->LastError();
exit;
}
while (! $RS->EOF)
{
$servername= $RS->Fields(0)->value;
print"servername is: $servername\n";
$RS->MoveNext;
}
$RS->Close;
$Conn->Close;
Feb 8, 2009
AIX 5.3 - install perl DBI and oracle DBD
1. down DBI http://search.cpan.org/~timb/DBI/
2. install DBI
perl Makefile.PL
make
make test
make install
3. download DBD http://search.cpan.org/~timb/DBD-Oracle-1.16/
$ perl Makefile.PL
Edit Makefile with following commands(OS and Oracle is 64bit,perl is 32bit. Need to set oracle lib as 32 bit):
1,$s?/lib/ ?/lib32/ ?g
1,$s?-q64??g
1,$s?/lib/sysliblist?/lib32/sysliblist?g
Now perform normal commands to perform the testing/making:
$ make
$ make test
$ make install
Feb 5, 2009
Oracle NLS_LANG environment setting meaning
NLS_LANG=<Language>_<Territory>.<Clients Characterset>
NLS_LANG各部分含義如下:
LANGUAGE指定:
-Oracle訊息使用的語言
-日期中月份和日顯示
TERRITORY指定
-貨幣和數位格式
-地區和計算星期及日期的習慣
CHARACTERSET:
-控制用戶端應用程式使用的字元集
通常設置或者等於用戶端(如Windows)內碼表
或者對於unicode應用設置為UTF8
在Windows上查看目前系統的內碼表可以使用chcp命令:
Example:
C:\>set NLS_LANG=TRADITIONAL CHINESE_TAIWAN.ZHT16MSWIN950
C:\>sqlplus "/ as sysdba"
SQL> select sysdate from dual;
SYSDATE
----------
01-11月-03
C:\>set NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252
C:\>sqlplus "/ as sysdba"
SQL> select sysdate from dual;
SYSDATE
----------
01-NOV-03