I am trying to execute a bash script from within a php script.
The php script is:
<?php
$clientName = $_POST['clientName'];
$startDate = $_POST['startDate'];
$endDate = $_POST['endDate'];
$mode = $_POST['mode'];
echo("Current working directory = " . getcwd());
echo("Client Name = " . $clientName . "<br/>\n");
echo("Start date = " . $startDate . "<br/>\n");
echo("End date = " . $endDate . "<br/>\n");
echo("Mode = " . $mode . "<br/>\n");
$cmd = "/webroot/argRepeater.bash escapeshellarg($clientName) escapeshellarg($startDate) escapeshellarg($endDate) escapeshellarg($mode)";
echo("Command = " . $cmd . "<br/>\n");
var_dump($cmd);
exec("/bin/bash ./argRepeater.bash escapeshellarg($clientName) escapeshellarg($startDate) escapeshellarg($endDate) escapeshellarg($mode)", $output, $output2);
echo("Output array = " . print_r($output) . "<br/>\n");
echo("Output = " . $output2 . "<br/>\n");
?>
The above php script takes arguments from an html form. The bash script argRepeater.bash only repeats whatever arguments were given to it. The output is as follows:
Current working directory = /home/content/31/10199331/htmlClient Name = yum
Start date = 2013-05-14
End date = 2013-05-24
Mode = fir
Command = ./argRepeater.bash escapeshellarg(yum) escapeshellarg(2013-05-14) escapeshellarg(2013-05-24) escapeshellarg(fir)
string(128) "./argRepeater.bash escapeshellarg(yum) escapeshellarg(2013-05-14) escapeshellarg(2013-05-24) escapeshellarg(fir)" Array ( ) Output array = 1
Output = 1
My questions:
1. What more needs to be done to ensure argRepeater gets executed?
2. How do I display argRepeater's outputs on the webpage?