未分类
Mac使用rz,sz远程上传或下载文件
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的路径
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
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 如下图所示:
1 2 3 4 5 6 7 |
Regular expression: \*\*B0100 Action: Run Silent Coprocess Parameters: /usr/local/bin/iterm2-send-zmodem.sh Regular expression: \*\*B00000000000000 Action: Run Silent Coprocess Parameters: /usr/local/bin/iterm2-recv-zmodem.sh |
现在就可以使用iTerm2终端便捷地从远程服务器上上传下载文件了