請教 expect腳本 如何獲得輸出結果# ssh登陸到服務器expect "#*"# 發送 pm2 ls |grep demo\r這個命令,希望得到服務器輸出的結果(結果如圖)send "pm2 ls |grep demo\r"# 如何得到上一條命令的結果,并賦值給變量resecho ${res}if [ #對res進行判斷 ]then fiexpect eof輸出的結果:謝謝各位大佬
2 回答

梵蒂岡之花
TA貢獻1900條經驗 獲得超5個贊
如果只是獲取 ssh 命令的輸出結果,我覺得用 expect 顯得復雜了,不如這樣
res=$(ssh user@host 'pm2 ls | grep demo') ...
- 2 回答
- 0 關注
- 2666 瀏覽
添加回答
舉報
0/150
提交
取消