SOLVED it’s not pretty but it works.
The issue was that PHP runs /bin/sh as it’s shell NOT bash ! /bin/sh is just a link to /bin/dash never heard of dash!
So I changed the link for /bin/sh to link to /bin/bash then modified my code to this:
$cmd = ““at $wtime $wdate <<< ‘sftp -a -r -P xxx [email protected]:’$file” /mnt/TRFR”"" ;
exec ("/bin/bash -c $cmd");
echo $cmd;
the -c is necessary.
Figuring out where to put single quotes, double quotes and what quotes to escape was the tricky bit after getting php to use bash in stead of dash.
dash it appears has no concept of <<<
exec ("/bin/bash -c $cmd"); <---- This does not work by itself. The command was still being executed by sh:
/bin/sh link still had to be changed to /bin/bash
I have now discovered why this is so. Regardless “at” executes all commands with /bin/sh so to get the <<< redirect to work I had to link /bin/sh to bash instead of dash as dash has no concept of <<<