• Mac下iterm2远程linux无法使用rz并提示waiting to receive.**B0100000023be50


    Mac下远程linux无法使用rz并提示waiting to receive.**B0100000023be50,还会卡一段时间,如图
    在这里插入图片描述

    原因:

    mac上的终端不支持rz和sz,需要借助iterm2软件并配置一下,才能使用

    解决:

    一.下载iterm2

    iterm2作为 mac 终端应用程序的替代品

    brew install --cask iterm2
    
    • 1

    二.安装lrzsz

    1.在mac下上安装 lrzsz

    brew install lrzsz
    
    • 1

    2.服务器上也要安装 lrzsz

    	# centos 
    	yum install lrzsz
    	#ubuntu
    	apt-get install lrzsz
    
    • 1
    • 2
    • 3
    • 4

    三.需要两个脚本

    1. 本地新建

    本地新建两个脚本放在/usr/local/bin目录下

    1.1 新建sz脚本

    vim /usr/local/bin/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 这个需要根据自己安装的文件位置编写
        /usr/local/bin/rz -E -e -b
        sleep 1
        echo
        echo
        echo \# Sent \-\> $FILE
    fi
    
    • 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
    1.2 新建rz脚本

    vim /usr/local/bin/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 这个需要根据自己安装的文件位置编写
    	/usr/local/bin/sz "$FILE" --escape --binary --bufsize 4096
    	sleep 1
    	echo
    	echo \# Received $FILE
    fi
    
    • 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
    2. 直接下载

    下载到/usr/local/bin目录下

    cd /usr/local/bin 
    wget https://raw.githubusercontent.com/sugar-cookie/iterm2-zmodem/main/iterm2-send-zmodem.sh 
    wget https://raw.githubusercontent.com/sugar-cookie/iterm2-zmodem/main/iterm2-recv-zmodem.sh
    
    • 1
    • 2
    • 3

    然后给这两个文件赋予权限

    chmod 777 /usr/local/bin/iterm2-*
    
    • 1

    四、配置iterm2

    接下来配置iterm2,选择你的Profiles的进行配置,点击 iTerm2 的设置界面 Perference-> Profiles -> Default -> Advanced -> Triggers 的 Edit 按钮

    在这里插入图片描述
    如下配置,就完成了
    在这里插入图片描述

    Regular expression: rz waiting to receive.\*\*B0100
                Action: Run Silent Coprocess
            Parameters: /usr/local/bin/iterm2-send-zmodem.sh
               Instant: checked
    
    Regular expression: \*\*B00000000000000
                Action: Run Silent Coprocess
            Parameters: /usr/local/bin/iterm2-recv-zmodem.sh
               Instant: checked
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    注意

    • 上面是iterm2-send-zmodem.sh 下面是iterm2-recv-zmodem.sh 一定不能放反位置了 要不然上传下载命令执行也会反着的
    • iterm2使用rz命令Received显示成功,但是ls找不到文件,可能登录的时候使用了expect脚本,手动登录试一下,ssh -p 22 root@ip
  • 相关阅读:
    【附源码】计算机毕业设计JAVA学习自律养成小程序后台
    分类预测 | Matlab实现SO-RF蛇群算法优化随机森林多输入分类预测
    【Python】Python 序列化
    钉钉小程序入门3—钉钉扫码登录PC端网站
    【机器学习】深度神经网络(DNN):原理、应用与代码实践
    StableSwarmUI:功能强大且易于使用的Stable Diffusion WebUI
    TypeError: __init__() got an unexpected keyword argument ‘transport_options‘
    20000字深度讲解 Python 数据可视化神器 Plotly
    yolov4 预测框解码详解【附代码】
    Vue跨域配置
  • 原文地址:https://blog.csdn.net/sugar_cookie/article/details/126596472