I'm having problems trying to run the following script through php using the shell_exec() function.
#!/bin/bash
/usr/bin/sshpass -p 'password' /usr/bin/rsync -avzhe -O
"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p port"
--exclude '*html' --include='R*' --exclude '*'
username@ipaddress:/location/ /location
When I run this script in Terminal or through php shell_exec() I receive the following error:
Unexpected remote arg: username@IP:/location/
rsync error: syntax or usage error (code 1) at main.c(1201) [sender=3.0.6]
If I remove the '-O' from the rsync part it works fine in terminal but through php I get the following error:
rsync: failed to set times on "/destination_location/.": Operation not permitted (1)
rsync: mkstemp "/location/.file.pSnb11" failed: Permission denied (13)
rsync: mkstemp "/location/.file.hR7VUM" failed: Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1505) [generator=
Below is the php code.
<?php
if (isset($_POST['button']))
{
shell_exec('/location/rsync.sh');
}
?>
<html>
<body>
<form method="post">
<p>
<button name="button">Run Script</button>
</p>
</form>
</body>