都是工作中遇到的问题,记下来以免以后要用到:
1 批处理读文件:
set /p MString=<filename.txt
echo %MString%
此代码只读入一行
2 将access的query 导出为csv
Function exportDetail(QueryName As String)
Dim time As String
Dim tmp As String
time = Format(Now(), "General Date")
tmp = Replace(Replace(time, "/", "_"), ":", "_")
curpath = Environ("workPath")
filenamestr = curpath & "\" & QueryName + "_" + tmp & ".csv"
Dim str As String
str = QueryName + "_" + tmp & ".csv"
Open curpath & "\" & "filename.txt" For Output As #1
Print #1, str
Close #1
DoCmd.TransferText TransferType:=acExportDelim, _
TableName:=QueryName, FileName:=filenamestr, HasFieldNames:=True
End Function
3 Perl发送邮件(带附件)
#! /usr/local/bin/perl -w
use Mail::Sender;
#command line parameters
my $to = $ARGV[0];
my $subject = $ARGV[1];
my $file = $ARGV[2];
#my $today_ = `date /t 2>&1`;
#chomp ($today_);
#get the correct number of args
sub validateArgs(@) {
$argSize = @ARGV;
if ($argSize < 3) {
print "You must enter 3 parameters: \"to\" \"subject\" filename \n";
exit 101;
}
}
sub mail{
ref ($sender = new Mail::Sender { from => '发件人',
smtp => 'na.relay.ibm.com', boundary => 'This-is-a-mail-boundary-435427'})
or die "Error($sender) : $Mail::Sender::Error\n";
$sender->OpenMultipart({to => $to,
subject => $subject});
$sender->Body;
$sender->SendEnc(<<'*END*');
Attachment is test!
*END*
$sender->Attach(
{description => 'test',
ctype => '',
encoding => '',
disposition => '',
file => $file
});
$sender->Close;
}
#MAIN
select STDERR;
$| = 1;
select STDOUT;
$| = 1;
validateArgs(@ARGV);
mail();
exit(0);
1 批处理读文件:
set /p MString=<filename.txt
echo %MString%
此代码只读入一行
2 将access的query 导出为csv
Function exportDetail(QueryName As String)
Dim time As String
Dim tmp As String
time = Format(Now(), "General Date")
tmp = Replace(Replace(time, "/", "_"), ":", "_")
curpath = Environ("workPath")
filenamestr = curpath & "\" & QueryName + "_" + tmp & ".csv"
Dim str As String
str = QueryName + "_" + tmp & ".csv"
Open curpath & "\" & "filename.txt" For Output As #1
Print #1, str
Close #1
DoCmd.TransferText TransferType:=acExportDelim, _
TableName:=QueryName, FileName:=filenamestr, HasFieldNames:=True
End Function
3 Perl发送邮件(带附件)
#! /usr/local/bin/perl -w
use Mail::Sender;
#command line parameters
my $to = $ARGV[0];
my $subject = $ARGV[1];
my $file = $ARGV[2];
#my $today_ = `date /t 2>&1`;
#chomp ($today_);
#get the correct number of args
sub validateArgs(@) {
$argSize = @ARGV;
if ($argSize < 3) {
print "You must enter 3 parameters: \"to\" \"subject\" filename \n";
exit 101;
}
}
sub mail{
ref ($sender = new Mail::Sender { from => '发件人',
smtp => 'na.relay.ibm.com', boundary => 'This-is-a-mail-boundary-435427'})
or die "Error($sender) : $Mail::Sender::Error\n";
$sender->OpenMultipart({to => $to,
subject => $subject});
$sender->Body;
$sender->SendEnc(<<'*END*');
Attachment is test!
*END*
$sender->Attach(
{description => 'test',
ctype => '',
encoding => '',
disposition => '',
file => $file
});
$sender->Close;
}
#MAIN
select STDERR;
$| = 1;
select STDOUT;
$| = 1;
validateArgs(@ARGV);
mail();
exit(0);