LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-28-2004, 08:44 AM   #1
didi86
Member
 
Registered: Jun 2004
Distribution: OpenSuSE, CentOS, Linux From Scratch
Posts: 40

Rep: Reputation: 15
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...
 
Old 11-28-2004, 12:35 PM   #2
megaspaz
Senior Member
 
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
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.
 
Old 11-28-2004, 02:29 PM   #3
didi86
Member
 
Registered: Jun 2004
Distribution: OpenSuSE, CentOS, Linux From Scratch
Posts: 40

Original Poster
Rep: Reputation: 15
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?

Last edited by didi86; 11-28-2004 at 02:48 PM.
 
Old 11-28-2004, 03:24 PM   #4
megaspaz
Senior Member
 
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054

Rep: Reputation: 46
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.

Last edited by megaspaz; 11-28-2004 at 03:26 PM.
 
Old 11-28-2004, 04:02 PM   #5
didi86
Member
 
Registered: Jun 2004
Distribution: OpenSuSE, CentOS, Linux From Scratch
Posts: 40

Original Poster
Rep: Reputation: 15
What would my script have to look like if I want it to run "shutdown -<var1> <var2>"?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
running shell script: command not found tripat Red Hat 3 04-14-2010 01:21 PM
Running a shell script remotely via 'ssh <hostname> <command>' davee Linux - General 4 10-09-2005 01:38 AM
Failed to start apache : Apache does not appear to be running : number11 Slackware 9 02-11-2005 09:51 AM
what OS is my shell account running? rid00z Linux - Newbie 1 10-13-2003 05:08 AM
Running a shell command containing awk and grep within a C program Linh Programming 1 06-05-2003 06:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration