mac iterm2 rz sz 无法上传下载问题

一、问题状况

在mac上使用brew install lrzsz命令安装后,根据网上一些文章的步骤,修改iterm2的Triggers。但是在远程服务器上执行rz命令,想将本地文件上传到服务器时,命令卡住了:

$ rz
?**B0100000023be50ive.**B0100000023be50

二、如何解决

1、安装lrzsz

brew install lrzsz

##至于mac上brew工具没有安装的的,可以提前安装

2、查看lrzsz工具所在路径

brew list lrzsz  

##这一步很关键,因为路径下存在rz、sz两个工具。
term2-send-zmodem.sh和iterm2-recv-zmodem.sh两个脚本只是对这两个工具的简单封装,

3、下载iterm2-zmodem脚本文件: 脚本地址链接

下载解压后,获取到的就是上述提到的term2-send-zmodem.sh和iterm2-recv-zmodem.sh两个脚本

4、修改脚本

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

osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; then
	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)&\"\")"`
else
	FILE=`osascript -e 'tell application "iTerm2" to activate' -e 'tell application "iTerm2" 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)&\"\")"`
fi

if [[ $FILE = "" ]]; then
	echo Cancelled.
	# Send ZModem cancel
	echo -e \\x18\\x18\\x18\\x18\\x18
	sleep 1
	echo
	echo \# Cancelled transfer
else
	cd "$FILE"
	/usr/local/bin/rz -E -e -b   ##/usr/local/bin/rz这个rz工具路径改为brew list lrzsz 时获取到的路径
	sleep 1
	echo
	echo
	echo \# Sent \-\> $FILE
fi

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

osascript -e 'tell application "iTerm2" to version' > /dev/null 2>&1 && NAME=iTerm2 || NAME=iTerm
if [[ $NAME = "iTerm" ]]; then
	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)&\"\")"`
else
	FILE=`osascript -e 'tell application "iTerm2" to activate' -e 'tell application "iTerm2" 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)&\"\")"`
fi
if [[ $FILE = "" ]]; then
	echo Cancelled.
	# Send ZModem cancel
	echo -e \\x18\\x18\\x18\\x18\\x18
	sleep 1
	echo
	echo \# Cancelled transfer
else
	/usr/local/bin/sz "$FILE" -e -b    ##/usr/local/bin/rz这个rz工具路径改为brew list lrzsz 时获取到的路径
	sleep 1
	echo
	echo \# Received $FILE
fi

5、修改iterm2的Triggers

iterm2工具上:
Settings> Profiles -> Default -> Advanced -> Triggers 的 Edit 按钮

修改内容:
rz waiting to receive.\*\*B0100
xxx/iterm2-send-zmodem.sh     ##iterm2-send-zmodem.sh的存放路径

\*\*B00000000000000
xxx/iterm2-recv-zmodem.sh    #iterm2-recv-zmodem.sh的存放路径

至此到远程服务器上,使用rz上传本地文件成功

相关推荐
Kslient3 小时前
Charles mac电脑配置
macos
归辞...16 小时前
暑假第四周——天气预报仿写
macos·objective-c·cocoa
安和昂21 小时前
【iOS】push和present的区别
macos·ios·cocoa
牛奔1 天前
mac 如何开启指定端口供外部访问?
macos
鹏大师运维1 天前
Mac M芯片上安装统信UOS 1070arm64虚拟机
linux·macos·信创·国产化·arm64·统信·uos1070
浏览器爱好者1 天前
macOS上谷歌浏览器的十大隐藏功能
macos
tubage20232 天前
Benvista PhotoZoom Pro / Classic 9.0.2 Win/mac + Plug-in中文破解版
macos·电脑·photozoom·photozoom 9
lzhdim2 天前
苹果宣布iOS 18正式版9月17日推送:支持27款iPhone升级
macos·ios·objective-c·cocoa·iphone
键盘敲没电2 天前
【iOS】属性关键字
macos·ios·cocoa
我和我的顶顶年华2 天前
如何在mac上玩使命召唤手游?苹果电脑好玩的第一人称射击游戏推荐
游戏·macos·容器·电脑·macbook·使命召唤·crossover免费下载