百度空间 | 百度首页 
 
查看文章
 
linux上面的sz,rz命令与ssh的配合
2009年05月13日 星期三 01:16

问题的提出:
一般来说,linux服务器大多是通过ssh客户端来进行远程的登陆和管理的,使用ssh登陆linux主机以后,如何能够快速的和本地机器进行文件的交互呢,也就是上传和下载文件到服务器和本地;
与ssh有关的两个命令可以提供很方便的操作:
   sz:将选定的文件发送(send)到本地机器
   rz:运行该命令会弹出一个文件选择窗口,从本地选择文件上传到服务器(receive)
  
当然,还可以设置一下目录了:
设置一下上传和下载的默认目录
options–>session options–>file transfer 下可以设置上传和下载的目录
剩下的你只要在用SecureCRT登陆linux终端的时候:
发送文件到客户端:sz filename
zmodem接收可以自行启动.
从客户端上传文件到linux服务端:
只要服务端执行 : rz
然后在 SecureCRT 里选文件发送,协议 zmodem
简单吧,如果你以前一直使用ssh,而又没有对外开放ftp服务,你就直接使用这种方式来传输你的文件

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/18199/showart_106830.html

我想还有很多人没有听说过ZModem协议,更不知道有rz/sz这样方便的工具。
好东西不敢独享。以下给出我知道的一点皮毛。
下面一段是从SecureCRT的帮助中copy的:
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就可以用SecureCRT登陆到Unix/Linux主机(telnet或ssh均可)
O 运行命令rz,即是接收文件,SecureCRT就会弹出文件选择对话框,选好文件之后关闭对话框,文件就会上传到当前目录
O 运行命令sz file1 file2就是发文件到windows上(保存的目录是可以配置) 比ftp命令方便多了,而且服务器不用再开FTP服务了
PS:Linux上rz/sz这两个小工具安装lrzsz-x.x.xx.rpm即可,Unix可用源码自行 编译,Solaris spac的可以到sunfreeware下载执行码

一、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

类别:linux篇 | 添加到搜藏 | 浏览() | 评论 (1)
 
最近读者:
 
网友评论:
1
2009年07月16日 星期四 20:31 | 回复
很详细!!!!!!
 
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu