首先,這似乎是一個重復的問題,但我已經搜索了堆疊溢位/各種其他論壇站點,但仍然沒有找到解決方案。
我已經查看了一些示例論壇帖子,以證明我在提問之前已經完成了研究:
- https://superuser.com/questions/130443/remotely-run-script-on-unix-get-output-locally
- https://linuxconfig.org/executing-commands-remotely-with-ssh-and-output-redirection
- https://zaiste.net/posts/few-ways-to-execute-commands-remotely-ssh/
- https://unix.stackexchange.com/questions/474533/get-output-of-this-command-from-another-server-via-ssh
- 運行 ssh 并立即執行命令
- https://www.cyberciti.biz/faq/unix-linux-execute-command-using-ssh/
還有數百個,但我不會全部包括在內。
我基本上需要一個 shell 腳本來在 Windows 上打開命令提示符,登錄到遠程 linux 系統并運行命令。
我知道這可以通過以下方式完成:
start cmd /k ssh user@host ls
但是上面的問題是ssh連接在任務完成后關閉。我也知道我可以通過添加以下內容來保持 ssh 連接打開:
bash -l
在某些情況下。
對于我的用例,我需要為 ROS(機器人作業系統)運行啟動檔案,為此我需要查看命令的輸出。
并且在嘗試運行 roslaunch launchFile.launch (代替上面的 ls )時:
start cmd /k ssh user@host "roslaunch launchFile.launch"
命令提示符回傳
bash: roslaunch: command not found
我顯然已經清理了我的啟動檔案的具體名稱,但是
roslaunch launchFile.launch
如果我先登錄到 linux PC,則運行完美:
ssh user@host
然后運行命令。
我已經在 MacOS 上實作了這個確切的用例,但我現在需要在 Windows 上重新實作相同的解決方案:
osascript -e 'tell app "Terminal"
do script "ssh [email protected] \n
roslaunch launchFile.launch"
end tell'
提前感謝您的任何幫助或建議。
uj5u.com熱心網友回復:
試試這個 :
start cmd /k ssh user@host "/full/path/to/roslaunch launchFile.launch; exec /bin/bash"
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/470005.html
上一篇:在Spyder中添加庫