python实现shell的eof,如何使用Perl或Python将EOF附加到文件?

I’m trying to bulk insert data to SQL server express database. When doing bcp from Windows XP command prompt, I get the following error:

C:\temp>bcp in -T -f -S

Starting copy...

SQLState = S1000, NativeError = 0

Error = [Microsoft][SQL Native Client]Unexpected EOF encountered in BCP data-file

0 rows copied.

Network packet size (bytes): 4096

Clock Time (ms.) Total : 4391

So, there is a problem with EOF. How to append a correct EOF character to this file using Perl or Python?

解决方案

EOF is End Of File. What probably occurred is that the file is not complete; the software expects data, but there is none to be had anymore.

These kinds of things happen when:

the export is interrupted (quit dump software while dumping)

while copying the dumpfile aborting the copy

disk full during dump

these kinds of things.

By the way, though EOF is usually just an end of file, there does exist an EOF character. This is used because terminal (command line) input doesn't really end like a file does, but it sometimes is necessary to pass an EOF to such a utility. I don't think it's used in real files, at least not to indicate an end of file. The file system knows perfectly well when the file has ended, it doesn't need an indicator to find that out.

EDIT shamelessly copied from a comment provided by John Machin

It can happen (uninentionally) in real files. All it needs is (1) a data-entry user to type Ctrl-Z by mistake, see nothing on the screen, type the intended Shift-Z, and keep going and (2) validation software (written by e.g. the company president's nephew) which happily accepts Ctrl-anykey in text fields and your database has a little bomb in it, just waiting for someone to produce a query to a flat file.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值