LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   running shell command with apache (https://www.linuxquestions.org/questions/linux-software-2/running-shell-command-with-apache-260137/)

didi86 11-28-2004 08:44 AM

running shell command with apache
 
Is there a way to run a shell command from a website hosted on apache? I'm trying to figure out a way to restart my linux server with a web-interface...

megaspaz 11-28-2004 12:35 PM

you could create a cgi script in perl and use perl's exec or system function to execute a shell command or shell script. or you can just use a shell script and tell apache in the configuration file to treat something with a *.sh extension as a cgi script and execute it.

didi86 11-28-2004 02:29 PM

I think I like the cgi-version best, since I don't know anything about perl, but: is there a way to give some variables to a cgi script?

megaspaz 11-28-2004 03:24 PM

yes, you can always pass variables to a cgi script provided you write your code to look for the variables. the easiest way is to pass the variables (key/value pairs) to your script is by passing them inside the url seperating multiple variables (key/value pairs) by '&'.

ex.
Code:

http://someplace.com/some_cgi.cgi?some_var1=some_val1&some_var2=some_val2
the script would then get the value of some_var1 and some_var2 and process them in some way.

didi86 11-28-2004 04:02 PM

What would my script have to look like if I want it to run "shutdown -<var1> <var2>"?


All times are GMT -5. The time now is 05:48 PM.