试图运行一个用PHP脚本启动套接字的shell脚本

I’m trying to automate the process of running a shell script when I connect to a wifi access point hosted by a pi zero. I have nodogsplash redirecting to a php file. That file currently contains this code:

<?php

$ipaddress = getenv("REMOTE_ADDR");
echo $ipaddress

$cmd = 'startconn.sh $ipaddress';

while (@ ob_end_flush()); // end all output buffers if any
$proc = popen($cmd, 'r'); echo '<pre>'; while (!feof($proc)) {
echo fread($proc, 4096);
@ flush();
}
echo '</pre>';

?>

The shell script ‘startconn.sh’ opens a socket and runs continual telemetry data (mavlink) between the host and the client. I’ve tried a few variations of this but have not been successfull yet. I have however been successful in running the shell script manually and having the two machines function properly.

Can anyone help me to get the php script to start the shellscript?

Thanks,

Loren