ssh@host:""ssh切换到其他机器上执行多条命令;Pseudo-terminal will not be allocated because stdin is not a terminal.
terminal
The new Windows Terminal and the original Windows console host, all in the same place!
项目地址:https://gitcode.com/gh_mirrors/term/terminal
免费下载资源
·
1.背景:shell脚本在主机器上执行kafka的启动命令,其他机器也会起这个进程。
之前的脚本每次执行的时候出现卡住的现象,不能回到命令行。
解决方法:
第一种
#/bin/bash
KAFKA_HOME=/opt/kafka
source /opt/wyl/cfg.config
su - hadoop <<EOF
for mm in ${ip[*]};do
echo "===>"\${mm}:
ssh hadoop@\${mm} "cd /opt/kafka ; nohup ./bin/kafka-server-start.sh ${KAFKA_HOME}/config/server.properties > /opt/kafka/kafka.log & [ $? -eq 0 ] && echo 'kafka is start...' "
done
EOF
其中ip就是所有需要执行的机器列表。
ssh hadoop@${mm}后续必须要跟双引号
其中分号是分隔命令的作用
/opt/kafka/kafka.log 是将日志打印到这个地方
第二种:
ssh root@ip << remotessh
首先要ssh上去,ssh的配置可以看我的上一篇文章,注意这里的<< remotessh
从这里开始都是在远程机器上执行命令啦
cd /tmp/test/
rm -f test.txt
cat test.log | grep ‘test’ >> test.txt
echo “finished!”
执行完毕
exit ###不要忘记退出远程机器
remotessh ###还有这里的结尾哦,不要忘记
#!/bin/bash
2 KAFKA_HOME=/opt/kafka
3 source /opt/wyl/cfg.config
4 su - hadoop <<EOF
5 for mm in ${ip[*]};do
6 echo "===>"\${mm}:
7 ssh -Tq hadoop@\${mm} << remotessh
8 cd /opt/kafka #要顶格写,不然会报错的
9 nohup ./bin/kafka-server-start.sh ${KAFKA_HOME}/config/server.properties > /opt/kafka/kafka.log & #要顶格写,不然会报错的
10 [ $? -eq 0 ] && echo 'kafka is start...' #要顶格写,不然会报错的
11 exit
12 remotessh
13 done
14 EOF
这种方法执行脚本之后,会打印出
Pseudo-terminal will not be allocated because stdin is not a terminal.
字面意思是伪终端将无法分配,因为标准输入不是终端。
强迫症的人肯定感觉很烦的。
这个时候我们可以加上参数去解决这个问题。
所以需要增加-tt参数来强制伪终端分配,即使标准输入不是终端。
或者加上-Tq这个参数也可以。
加上-tt运行结果: ssh -tt hadoop@’xxxx’
每个终端都打印出执行的命令
加上-Tq的运行结果 ssh -Tq hadoop@’xxxx’
GitHub 加速计划 / term / terminal
94.53 K
8.17 K
下载
The new Windows Terminal and the original Windows console host, all in the same place!
最近提交(Master分支:2 个月前 )
d04381ec
"HighContrast" is not a possible requested theme. So `_UpdateBackgroundForMica()` would force the settings UI to be light or dark. To fix this, we just check if we're in high contrast mode and, if so, we don't bother setting the requested theme. 8 天前
e83434ff
Turns out that having the styles for the KeyChordText and ParsedCommandLineText be empty for high contrast mode caused the issue. Since we're already using theme resources for the colors, we automatically adjust properly to whatever the high contrast theme is (Thanks XAML!).
Bonus points:
- we didn't need the theme dictionaries anymore, so I just moved them to the ResourceDictionary directly
- ParsedCommandLineTextBlockStyle isn't used. So I removed it altogether.
Validated command palette with multiple high contrast themes. See PR thread for demo.
Closes #17914 8 天前
更多推荐
已为社区贡献4条内容
所有评论(0)