查看文章 |
问题的提出:
我想还有很多人没有听说过ZModem协议,更不知道有rz/sz这样方便的工具。
一、linux 与 windows 文件传输:rz/sz ZModem is a full-duplex file transfer protocol that supports fast data transfer rates and effective error detection. ZModem is very user friendly, allowing either the sending or receiving party to initiate a file transfer. ZModem supports multiple file ("batch") transfers, and allows the use of wildcards when specifying filenames. ZModem also supports resuming most prior ZModem file transfer attempts. rz,sz是便是Linux/Unix同Windows进行ZModem文件传输的命令行工具 windows端需要支持ZModem的telnet/ssh客户端(比如SecureCRT) 运行命令rz,即是接收文件,SecureCRT就会弹出文件选择对话框,选好文件之后关闭对话框,文件就会上传到当前目录 注意:单独用rz会有两个问题:上传中断、上传文件变化(md5不同),解决办法是上传是用rz -be,并且去掉弹出的对话框中“Upload files as ASCII”前的勾选。 -b binary 用binary的方式上传下载,不解释字符为ascii -e 强制escape 所有控制字符,比如Ctrl+x,DEL等 运行命令sz file1 file2就是发文件到windows上(保存的目录是可以配置) 比ftp命令方便多了,而且服务器不用再开FTP服务了 PS:Linux上rz/sz这两个小工具安装lrzsz-x.x.xx.rpm即可。 用binary和ascii上传究竟有什么区别呢?引一段E文: Ascii or Binary? The general rule of thumb is if you can view the file in a text editor like notepad (ie. .html, .js, .css files etc) you should upload in ASCII mode, most others (including images, sound files, video, zip files, executable's etc) should be uploaded in Binary. Exceptions to the Rule It seems all things related to computers have exceptions to the rules. Yes, this is yet another case of it. If your text files contain international characters (ie. Chinese or Japanese text), they are to be uploaded as binary. The reason is that ascii takes into account differences between DOS and UNIX files (7 bits) but it doesn't do well with text using higher bits. Why Does It Matter What Mode You Transfer Files With? If you upload images etc. as ascii you'll end up with corrupted files. Some browsers seem capable of figuring it out, but not all... and not all the time. Netscape is much more picky, so you'd end up with broken or missing pictures for your Netscape users. (Yup, I learned this the hard way :-o ) Same thing with uploading text files as binary. While this is less important for html files, scripts will have a HUGE problem with it and will just not work. This is the most common cause of the "Server 500 Error - Malformed Headers", and other equally unlovely errors that have caused many a webmaster to bang their heads against their computers. So What Does Uploading In ASCII Do? I'd wondered this for a while and finally decided to learn why uploading in ascii is so important for some file types. What I found out is that different Operating System's use different ways to specify that a line has ended. So if you're using a different operating system than your server (which is very likely), the files will have extra characters at the end of each line that the server doesn't recognize. So it'll usually print them out resulting in script errors. Setting Your FTP Program to "Auto"Most FTP programs have the option to set your upload to auto. What this usually does is compare the file type you're transferring against a list of known file types and set it to binary or ascii upload on its own. By default, most FTP programs will have a pre-set list of files to be transferred in ascii and will upload / download everything else in binary. (These settings are in different places depending on the program you are using. Check the "Read Me" file or their Website if you can't find it.) Be sure to double check that the files you want to transfer are in the appropriate list. SummaryASCII? Files .htm .html .shtml .php .pl .cgi .js .cnf .css .forward .htaccess .map .pwd .txt .grp .ctl Binary Files .jpg .gif .png .tif .exe .zip .sit .rar .ace .class .mid .ra .avi .ocx .wav .mp3 .au |