Reputation: 43
The first argument $htmlpageid
can be referenced to by $1
in the sh script.
The second argument should be referenced by $2
. Right?
<?php
$htmlpageid = uniqid();
$days ="1";
$command = shell_exec("sudo ./createclientcert.sh $htmlpageid $days");
?>
No matter what i try but i can't get the second argument $days
over to the script.
I tried several methods but none of them passes the second argument $days
.
Upvotes: 1
Views: 55
Reputation: 43
I made i mistake by referencing $days by $2 in the sh script because i referenced it inside a function definition.
Very sorry for this dumb thing. ;)
#!/bin/sh
newclient () {
echo "# valid from "$(date) "till "$(date --date='+'$2' day') >> /root/$1.ovpn
}
Instead I should had coded the command outside a function or called the function with the arguments passed to the script:
#!/bin/sh
newclient () {
echo "# valid from "$(date) "till "$(date --date='+'$2' day') >> /root/$1.ovpn
}
newclient $1 $2
Upvotes: 1