I cannot seem to get a variable passed to my bash script from php. $uaddress and $upassword come up empty no matter what I try.
******<
Got it.
<?php
$upassword = 'test1234'; $uaddress = 'mytestuser@tpcmedia.com';
$uaddress = escapeshellarg($uaddress);
$upassword = escapeshellarg($upassword);
$addr = shell_exec("sudo /home/tpcmedia/cgi-bin/member_add_postfixadmin $uaddress $upassword 2>&1");
?>
#!/bin/bash -x
uaddress=$1
upassword=$2
ssh -p 2222 -6 2400:8900::f03c:91ff:fe69:8aaf "/var/www/localhost/htdocs/postfixadmin/scripts/postfixadmin-cli mailbox add" $uaddress --password $upassword --password2 $upassword
You need to pass the variables as arguments to the shell script, and the shell script has to read its arguments.
So in PHP:
$useraddress = escapeshellarg('mytestuser@tpccmedia.com');
$upassword = escapeshellarg('test1234');
$addr = shell_exec("sudo /home/tpccmedia/cgi-bin/member_add_postfixadmin $useraddress $upassword 2>&1");
and in the shell script:
useraddress=$1
upassword=$2