Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Developing an ASP.NET MVC web application and running it on Linux and mono. In this web application, some menu/button need to run the commands of linux. How can I execute Linux command from ASP.net/C# web application.
Thanks a lot.
Posted
Comments
Yvan Rodrigues 15-Jan-14 10:11am    
What have you tried? I would first look at the Process class.
Bernhard Hiller 16-Jan-14 2:52am    
Wait - the button is somewhere on a Web page shown in a browser, isn't it? And where is that Linux command to be executed - on the client computer, or on the server computer?

 
Share this answer
 
Comments
Sampath Lokuge 15-Jan-14 10:37am    
Hi Sergey,congratulations to you be the MVP in 2014 ! :)
Sergey Alexandrovich Kryukov 15-Jan-14 11:15am    
Thank you, Sampath.
—SA
Maciej Los 15-Jan-14 16:34pm    
+5
Sergey Alexandrovich Kryukov 15-Jan-14 18:43pm    
Thank you, Maciej.
—SA
Maciej Los 15-Jan-14 18:46pm    
You're welcome.
Is there everything OK? Were you sick or are you so busy?
You may run like this.

C#
process.StartInfo.FileName = "/usr/bin/sudo";
process.StartInfo.Arguments = "/sbin/shutdown -h now";


Check here for more info: linux using c# and mono

excute linux command under mono C#

Process Class
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900