Abhishek Gangadhar
Abhishek Gangadhar

Reputation: 117

Web application to run a shell script on the client machine?

I am trying to build a web application that executes shell scripts on the client side to extract data from the client side and save to extracted data as a zip file.

The client would specify the directory of the shell scripts or the shell script file.

How would I go about doing this task?

Upvotes: 0

Views: 3722

Answers (2)

Abhijit Pritam Dutta
Abhijit Pritam Dutta

Reputation: 5591

From you question it is not clear exactly what is your requirement. Only thing which is clear that how you can execute a shell script from your web application. If your web application is in Java you can use the below codes to do that. You might face issues while executing the shell script if your web application does not have enough permission to execute a file in that machine.

 String command ="/pathtoyourscript/yourscript.sh";
 Process p;
 try {
       p = Runtime.getRuntime().exec(command);
       p.waitFor();                  
} catch (Exception ex) {
       ex.printStackTrace();
}

Upvotes: 2

anupkholgade
anupkholgade

Reputation: 26

I can't really cant add a comment, but marcolz above is correct. What you are trying to do would require allowing the access to the web application account user ( e.g. apache in case apache server ) to local user account. Definitely can be done but very very risky.

Upvotes: 0

Related Questions