请教 expect脚本 如何获得输出结果# ssh登陆到服务器expect "#*"# 发送 pm2 ls |grep demo\r这个命令,希望得到服务器输出的结果(结果如图)send "pm2 ls |grep demo\r"# 如何得到上一条命令的结果,并赋值给变量resecho ${res}if [ #对res进行判断 ]then fiexpect eof输出的结果:谢谢各位大佬
2 回答

守候你守候我
TA贡献1802条经验 获得超10个赞
如果只是获取 ssh 命令的输出结果,我觉得用 expect 显得复杂了,不如这样
res=$(ssh user@host 'pm2 ls | grep demo') ...
- 2 回答
- 0 关注
- 568 浏览
添加回答
举报
0/150
提交
取消