tjbradford
Technical User
I'm trying to build a webpage that will take an input value and call a bash script i have.
it's to start off a certificate request and the input value is for the user who will be handed the certificate. however when running this from webpage it reports that the enrollment failed (this is almost instantly)
if i run the command as from shell it works fine, i wondered if it's because it need to call the script then leave it running in the background but putting a & at the end of the $cmd doesn't help
what can i do - im not even at beginner level in php
<?php
$Fname = $_POST["Fname"];
$Lname = $_POST["Lname"];
$TofD = $_POST["TofD"];
$cmd="bash /etc/opt/cisco-vpnclient/Profiles/enroll .$Fname. &";
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<html>
<head>
<title>INFO</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Certificate Name:<input type="text" size="12" maxlength="12" name="Fname"><br />
<input type="submit" value="submit" name="submit">
</form>
<?
} else {
echo "Submiting request for usename, ".$Fname." .<br />";
echo "<i>".$quote."</i><br />";
echo exec('whoami');
echo "You're favorite time is ".$TofD.", and you passed ".$education."!<br />";
echo '<pre>';
exec ($cmd);
echo '
</pre>
<hr />Last line of the output: ' . $last_line . '
<hr />Return value: ' . $retval;
}
?>
it's to start off a certificate request and the input value is for the user who will be handed the certificate. however when running this from webpage it reports that the enrollment failed (this is almost instantly)
if i run the command as from shell it works fine, i wondered if it's because it need to call the script then leave it running in the background but putting a & at the end of the $cmd doesn't help
what can i do - im not even at beginner level in php
<?php
$Fname = $_POST["Fname"];
$Lname = $_POST["Lname"];
$TofD = $_POST["TofD"];
$cmd="bash /etc/opt/cisco-vpnclient/Profiles/enroll .$Fname. &";
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<html>
<head>
<title>INFO</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Certificate Name:<input type="text" size="12" maxlength="12" name="Fname"><br />
<input type="submit" value="submit" name="submit">
</form>
<?
} else {
echo "Submiting request for usename, ".$Fname." .<br />";
echo "<i>".$quote."</i><br />";
echo exec('whoami');
echo "You're favorite time is ".$TofD.", and you passed ".$education."!<br />";
echo '<pre>';
exec ($cmd);
echo '
</pre>
<hr />Last line of the output: ' . $last_line . '
<hr />Return value: ' . $retval;
}
?>