2014-02-18 25 views
0

我很難從laymen的角度得到我的問題的答案。這可能是因爲我對這個問題缺乏瞭解,所以我正在沉迷於這個問題。我有一臺Windows機器,可以運行膩子工具並連接到一個Linux盒子。我運行「killall /bob/bin/myfile.out」,然後關閉putty,然後鍵入cmd提示符pscp.exe myfilet.out.2.3.4 [email protected]:/bob/bin/myfile.out。有人能告訴我如何將這些結合到一個單獨的Windows批處理文件中嗎?謝謝windows,putty,pscp合併成一個批處理文件,這有可能嗎?

回答

0

您可以使用免費命令行工具Plink通過SSH在外部服務器上運行命令。

@echo off 
Plink [email protected] "killall /bob/bin/myfile.out" 
pscp.exe myfilet.out.2.3.4 [email protected]:/bob/bin/myfile.out || echo an error occurred when copying the file. 

如果差錯電平由前一個命令設置||在第二行之後的命令將只運行。

+0

使用putty登錄到一個Linux機箱,[email protected]與-PW很好。但我不能用plink來到這個相同的位置,所以我可以運行bat文件或sh文件。任何幫助,將不勝感激。謝謝 – user3314404

0

我還不能添加評論,但是您能否詳細說明如何使用putty登錄,但是不能與plink完全一樣嗎? Plink不僅接受與putty相同的選項,但如果您在putty中保存了會話,則可以從plink訪問它。沒有任何子,砰砰基本上應該讓你CMD外殼看起來像粗膩子窗口,與子命令,它會執行他們,並返回:

C:\Users\riglerjo>plink savedputtysession hostname 
s9-chicago.accountservergroup.com 

C:\Users\riglerjo>plink savedputtysession 
Using username "rigler". 
# hostname 
s9-chicago.accountservergroup.com 
-bash-3.2$ exit 
logout 

上砰砰的選項運行遠程命令

相關問題