I believe the function you're looking for is 'shell_exec()':
http://us3.php.net/shell_exec
You can pass the 'field1' and 'field2' variable via command line to the shell script as well.
Something like this is what you are going to be doing:
The PHP Script:
Code:
<?php
$field1 = $_POST['field1'];
$field2 = $_POST['field2'];
...
if ($something == "something") {
if(shell_exec('/path/to/shell_script1.sh $field1 $field2')) {
print "The shell script executed without error!";
} else {
print "The shell script returned with an error!";
}
} elseif ($something == "somethingelse") {
if(shell_exec('/path/to/shell_script2.sh $field1 $field2')) {
print "The shell script executed without error!";
} else {
print "The shell script returned with an error!";
}
}
...
?>
What you are doing is passing '$field1' and '$field2' as a parameter to the shell script. Therefore, the shell script will look something like this:
Code:
#!/bin/bash
# $1 is the first parameter passed to the shell script
field1=$1
field2=$2
# Do whatever you want with the $Field1 and $field2 variable
#
# Such as /var/www/${field2}/web
#
# OR
#
# AuthType Basic
# AuthName "Members Only"
# AuthUserFile /var/www/${field1}/.htpasswd
# <limit GET PUT POST>
# require valid-user
# </limit>
Using brackets for the variables isn't necessary, but whenever I am embedding them like that in a line where there is no whitespace around the variable, I like to.
Hope that helps
Recent comments
6 hours 55 min ago
16 hours 23 min ago
17 hours 13 min ago
20 hours 46 min ago
1 day 1 hour ago
1 day 1 hour ago
1 day 3 hours ago
1 day 13 hours ago
1 day 18 hours ago
1 day 20 hours ago