LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Executing shell command from JSP file with command line arg from URL (http://www.linuxquestions.org/questions/programming-9/executing-shell-command-from-jsp-file-with-command-line-arg-from-url-919688/)

orcusomega 12-20-2011 11:41 AM

Executing shell command from JSP file with command line arg from URL
 
I have a home automation application that runs on Tomcat, and I am looking to extend the capabilities... Problem is I am not a programmer...

I am looking for a JSP script that will run a command line and use 2 values from the URL to define the action.

Example: The X10 SDK provides an executable (ahp.exe) that takes 2 command line options: device and status. The executable then sends the command to the device attached via USB. If I were trying to turn the device A10 to on, the command I would run at the command line would be "ahp.exe A10 ON".

So - long story short, I am looking to be able to go to a URL like this: localhost:8080/my.jsp?device=A10&status=ON and have that JSP run the command in the background. I don't care about getting feedback, I assume Tomcat will complain in its own logs if there is an issue.

Any help is appreciated - I have searched here and elsewhere, I suppose I am not looking up the right search strings....

Thanks!

Bob

hyperdaz 01-13-2012 10:29 AM

Shame your not running Linux and Bash... can do the very thing your asking for with cgi-scripts - I used it to stop - start and restart JBoss for humans.

Seems you are on Windows (ahp.exe) no clue if the same is possible, never tried.


http://www.linuxaria.com/article/bash-cgi?lang=en

orcusomega 01-13-2012 03:38 PM

Quote:

Originally Posted by hyperdaz (Post 4573694)
Shame your not running Linux and Bash... can do the very thing your asking for with cgi-scripts - I used it to stop - start and restart JBoss for humans.

Seems you are on Windows (ahp.exe) no clue if the same is possible, never tried.


http://www.linuxaria.com/article/bash-cgi?lang=en

Yes... It is a small system that has very little memory - one of the applications uses a Tomcat instance that I could potentially use to run command line commands through JSP. I could install apache and php, and that would work too - but i am trying to take advantage of what is already installed.

Thanks!

Bob


All times are GMT -5. The time now is 04:30 PM.