2013-02-13 57 views
0

我devlopping一個silverlight應用程序(C#),我需要運行在Linux服務器中找到一個shell腳本?如何從silverlight應用程序運行shell腳本?

can anyOne please please please?

+0

自己的SSH客戶端,我不認爲你想要什麼是可能的。然而,除非你給我們提供更多關於你想要達到的內容的信息(即這個shell腳本是做什麼的),我認爲任何人都不會提出任何明智的建議。 – ChrisF 2013-02-13 13:33:12

+1

你可以使用一個支持cgi的web服務器,並根據你正在做的事情運行腳本作爲cgi – technosaurus 2013-02-13 20:56:37

+0

我試圖執行一個shell腳本,它將在linux服務器機器上運行一個程序。該程序由Code Saturne開發。運行腳本運行庫將編譯SRC 目錄中的所有文件,並將它們與現有庫鏈接。做這樣的計算並帶來產出。 – 2013-02-14 14:36:35

回答

0

也許在Out of Browser模式下運行是您正在尋找的答案。

您可以從其中您的Silverlight程序集配置爲用高權限運行瀏覽器的OOB調用COM。從那裏你幾乎可以做任何事情。

例如:

if (Application.Current.HasElevatedPermissions && ComAutomationFactory.IsAvailable) 
{ 
    dynamic cmd = ComAutomationFactory.CreateObject("WScript.Shell"); 
    cmd.Run(@"c:\windows\notepad.exe", 1, true); 
} 

This article will help with setting up your project

Also note that this will only work in Windows, hence the check for ComAutomationFactory.IsAvailable

+0

我試圖執行一個Shell腳本,它將從客戶端運行Linux服務器機器上的程序! – 2013-02-14 14:38:25

1

@technosaurus是正確的。你可以使用cgi(perl,ruby等)或簡單的http請求到你的服務器。如:http://your-server-address/execute.php並使用php(或其他)命令shell_exec或ruby commands,或者您想要處理腳本輸出並將其發送給用戶。


實施例:
申請(IronRuby的):

host = "your_server_address" 
wclient = System::Net::WebClient.new 
wclient.download_string_completed{|wc, e| 
    # do something with e.Result 
} 
wclient_data.download_string_async(System::Uri.new("#{host}/get_users_dirs.php"))) 

get_users_dirs.php:

print shell_exec("bash ./get_users_dirs.sh"); 

get_user_dirs.sh

ls /home 

或者你可以開發像PuTTY