item2使用expect 自动ssh登录并且使用rzsz下载问题记录
登录脚本login.sh (和expect 脚本放在同一个目录)
#!/bin/sh
basepath=$(cd `dirname $0`; pwd)
export LC_CTYPE=zh_CN
export LANG=zh_CN.UTF-8
#expect脚本所在位置
filepath=$basepath/$1
echo $filepath
if [ -f $filepath ]; then
expect $filepath $2
else
echo "$filepath not exits"
fi
expect 脚本(k8s)
#!/usr/bin/expect -d
set host [lindex $argv 0]
set user root
set password 123456
set port 22
set timeout 30
spawn ssh $user@$host -p$port
expect {
"yes/no" {send "yes\r";exp_continue;}
"*password:*" { send "$password\r" }
}
interact
item2配置如下图所示
修订: 上面的sh 变为 bash,不然会出现格式上面的问题
遇到问题:
rzyz 无法上传下载以及中文乱码问题 参考
https://blog.csdn.net/yanjiee/article/details/122455207
#!/bin/bash
export LANG=zh_CN.UTF-8 # 这两句保障expect之后可以使用lrzsz
export LC_CTYPE=zh_CN
if [ $# -eq 0 ]; then
echo "usage: s host"
exit
fi
expect -c "
set timeout 5
spawn ssh user@192.168.1.120
expect \"Select group*\"
send \"s $1 $2\r\"
interact
"
这种情况下登陆的机器会出现rzsz之后中文乱码的问题。
通过注释mac主机下/etc/ssh/ssh_config中最后一行SendEnv LANG LC_* 就可以完美解决。
iterm2 配置
~/.zshrc
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="agnoster"
plugins=(git autojump zsh-autosuggestions zsh-syntax-highlighting sublime)
source $ZSH/oh-my-zsh.sh
source ~/.bash_profile
~/.bash_profile
#enables colorin the terminal bash shell export
export CLICOLOR=1
#setsup thecolor scheme for list export
export LSCOLORS=gxfxcxdxbxegedabagacad
#sets up theprompt color (currently a green similar to linux terminal)
#enables colorfor iTerm
export TERM=xterm-256color
[ -f /opt/homebrew/etc/profile.d/autojump.sh ] && . /opt/homebrew/etc/profile.d/autojump.sh
~/.vimrc
syntax on
set number
set ruler
mac 好用的工具
typro picGo sublime 解压专家oka owlocr utools BuhoCleaner w2