zoukankan      html  css  js  c++  java
  • 「MAC神操作」iterm2进行跳板机到服务器到上传和下载

    以前在windows上习惯于用xshell,即使有跳板机也可以上传和下载,不需要使用scp

    后来换mac了,十分不方便,同事先推荐使用app transmit,logo是一辆小货车,

    碰巧发现网上也有类似xshell 通过上传/下载  「rz/sz」的配置方法。

    具体如下,亲测有效。

    1. 服务器首先支持rz/sz命令

    brew install lrzsz

    2.Mac上安装安装Iterm2

    3.编写shell脚本用于上传和下载

    上传: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-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
    

      

    最好放在目录 /usr/local/bin/下,因为脚本里面写死了这个目录。

    并给这两个shell文件加上预定的权限,比如简单粗暴的chmod 777 iterm2*

    4. 配置Iterm2中的Triggers,具体入口是Perferences的Profiles标签页的Advanced标签页下面,Triggers点击Edit,然后新增如下,保存即可

        配置项:
    
        Regular expression        Action             Parameters
    
        **B0100        Run Silent Coprocess  /usr/local/bin/iterm2-send-zmodem.sh
    
        **B00000000000000   Run Silent Coprocess  /usr/local/bin/iterm2-recv-zmodem.sh
    

      

  • 相关阅读:
    正向代理与反向代理的区别
    显式拥塞通知ECN剖析
    Save info in Hidden Field
    sessionID difference
    Windows server 2003 无法找到Cookies位置
    create Cookie
    SQL Server Session
    New class in ASP.NET
    Save info in Query string
    Crypto number
  • 原文地址:https://www.cnblogs.com/qianjinyan/p/11956456.html
Copyright © 2011-2022 走看看