I have got this running fine in the terminal
rsync --info=progress2,stats source destion | stdbuf -oL awk 'BEGIN { RS="" } /%/ { print $2 }' > /temp/progress.txt
but when I try and move it over to PHP exec i run into errors
echo exec('rsync --info=progress2,stats source destion | stdbuf -oL awk 'BEGIN { RS="" } /%/ { print $2 }' > /temp/progress.txt');
I receive this error
mod_fcgid: stderr: PHP Parse error: syntax error, unexpected 'BEGIN' (T_STRING), expecting ',' or ')' in /home/laweb/public_html/phptest/copy.php on line 32
I have tried changing ' to " inside the exec(' ') command then I don't receive any output to the error log
You need to escape the single quotes within the string.
\'
So this line should fix it:
echo exec('rsync --info=progress2,stats source destion | stdbuf -oL awk \'BEGIN { RS="" } /%/ { print $2 }\' > /temp/progress.txt');
You are saying you get no output and the file does not copy, try shell_exec()
$output = shell_exec('rsync --info=progress2,stats source destion | stdbuf -oL awk \'BEGIN { RS="" } /%/ { print $2 }\' > /temp/progress.txt');
echo $output;
Now that i remember use escapeshellarg()
$command = escapeshellarg('rsync --info=progress2,stats source destion | stdbuf -oL awk \'BEGIN { RS="" } /%/ { print $2 }\' > /temp/progress.txt');
echo exec($command);