[英]Open a new terminal window and execute command in it by java without using bash script
[英]Open New Terminal Window from Perl Script and Execute SSH command
我有一個當前的perl腳本,我正在cygwin的Windows機器上執行該腳本,該腳本正在打開一個新的cygwin終端窗口並ssh'進入遠程機器。
嘗試在Mac上復制mintty命令。
if ($noexec) {
system("echo mintty -s 160,40 $cursor -o
BackgroundColour=$color -o
Title='\"$title\"' -e ssh $url \&");
} else {
system("mintty -s 160,40 $cursor -o BackgroundColour=$color -o
Title=\"$title\" -e ssh $url \&");
}
這是使用Applescript執行任務的代碼的簡單翻譯,如建議的副本中所述:在新的Mac OS X終端窗口中運行命令
if ($noexec) {
system(qq{echo osascript -e 'tell application "Terminal" to do script "ssh $url \& "'});
} else {
system(qq{osascript -e 'tell application "Terminal" to do script "ssh $url \& "'});
}
在后台運行ssh
命令似乎很奇怪。 可能您應該將\\&
替換為; exit
; exit
。
我不確定mintty
選項的含義(我想將幾何設置為160x40並選擇一個特定的光標嗎?),所以我沒有嘗試實現它們。 例如,https: //superuser.com/questions/1188772/mac-command-to-change-the-background-color-in-a-terminal演示了如何通過Applescript在終端中設置背景色。
如果mintty
或Windows ssh
確實接受要連接的URL(例如ssh://username@hostname
類的東西?),則必須將其拆開並僅提取U * x ssh
可接受的參數(例如username@hostname
沒有ssh://
協議說明符)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.