2013-02-13 135 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