当前位置: 首页 > article >正文

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上传本地文件成功


http://www.kler.cn/a/286672.html

相关文章:

  • CVE-2025-0411 7-zip 漏洞复现
  • 接口(完)
  • 2025牛客寒假算法基础集训营2
  • Jadx动态调试安卓逆向
  • 科普篇 | “机架、塔式、刀片”三类服务器对比
  • kotlin内联函数——takeIf和takeUnless
  • 深度学习系列73:使用rapidStructure进行版面分析
  • k3s安装部署说明
  • Bean 的实例化(创建 | 获取)
  • Prometheus和Grafana构建现代服务器监控体系
  • 数据结构之最短路径
  • RAG+知识图谱
  • Linux 背景、命令
  • JAVAEE初阶第一节——计算机的工作原理
  • C++国密SM2算法加解密的使用
  • vue3+elementplus的表格展示和分页实战
  • Oracle超详细(数据库编程)
  • vim 简易配置
  • 一键解决LBP2900通信错误的问题(同样支持Win 11系统)
  • 计算机毕业设计选题-基于python的OA办公管理系统【python-爬虫-大数据定制】
  • kubernetes培训
  • 深入探讨Java JSON解析与HTML标签清除:详解与实例
  • Vue3入门 - 解决pinia判断用户是否登录相关错误
  • 【系统架构设计】嵌入式系统设计(1)
  • sql靶场笔记
  • vue3监听键盘长按