注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

碳基体

http://weibo.com/tanjiti

 
 
 
 
 

日志

 
 

Mac使用rz,sz远程上传或下载文件  

2014-02-20 14:52:39|  分类: basic |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
SecureCRT有个很便捷的文件上传下载工具sz与rz,我们同样可以把这样的便捷带到mac上,只是稍微有一点点麻烦

第一步:下载并安装iterm2  

地址:http://www.iterm2.com/#/section/downloads

第二步: 下载并安装lrzsz


brew install lrzsz

安装成功后,会在以下路径生成两个可执行文件(具体的路径取决于brew配置,可以用find查找一下)

/usr/local/Cellar/lrzsz/0.12.20/bin/rz

/usr/local/Cellar/lrzsz/0.12.20/bin/sz


建立符号连接

ln -s /usr/local/Cellar/lrzsz/0.12.20/bin/sz /usr/local/bin/sz

ln -s /usr/local/Cellar/lrzsz/0.12.20/bin/rz /usr/local/bin/rz



第三步:下载并安装automatic zmoderm for iTerm2

源码:https://github.com/mmastrac/iterm2-zmodem

注意黄色字体,需要修改为实际sz与rz的路径

cd /usr/local/bin/

wget https://raw.github.com/mmastrac/iterm2-zmodem/master/iterm2-send-zmodem.sh

vim iterm2-send-zmodem.sh

#!/bin/bash


# Author: Matt Mastracci (matthew@mastracci.com)


# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script


# licensed under cc-wiki with attribution required 


# Remainder of script public domain




FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`


if [[ $FILE = "" ]]; then


        echo Cancelled.


        # Send ZModem cancel


        echo -e \\x18\\x18\\x18\\x18\\x18


        echo \# Cancelled transfer


        echo


else


        echo $FILE


        /usr/local/bin/sz "$FILE"


        echo \# Received $FILE


        echo


fi



wget https://raw.github.com/mmastrac/iterm2-zmodem/master/iterm2-recv-zmodem.sh

vim iterm2-recv-zmodem.sh 


#!/bin/bash


# Author: Matt Mastracci (matthew@mastracci.com)


# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script


# licensed under cc-wiki with attribution required 


# Remainder of script public domain




FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`


if [[ $FILE = "" ]]; then


        echo Cancelled.


        # Send ZModem cancel


        echo -e \\x18\\x18\\x18\\x18\\x18


        echo \# Cancelled transfer


        echo


else


        echo $FILE


        cd "$FILE"


        /usr/local/bin/rz


        echo \# Received $FILE


        echo


fi



第四步:编写相应的iTerm2 trigger
iTerm2-Profiles-Open Profiles-Edit Profiles-Advanced-Edit Trigger
如下图所示:
Mac使用rz,sz远程上传或下载文件 - 碳基体 - 碳基体
 
 现在就可以使用iTerm2终端便捷地从远程服务器上上传下载文件了
  评论这张
 
阅读(9004)| 评论(0)
推荐

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017