I am trying to run a simple cron job in cpanel, so that the files which are modified in the last 24 hours can be transferred to another server.But the problem is I don't know much about php.My code is:
<?php
#!/usr/bin/expect -f
$line1=shell_exec('spawn ssh user@hostname');
$line2=shell_exec('expect "password:"');
$line3=shell_exec('send "mypassword"');
$line4=shell_exec('interact');
$line5=shell_exec('find srcdirectory -maxdepth 1 -mtime -1 -exec scp -r "{}" user@hostname:targetdirectory \;');
echo "<pre>$line1</pre>";
echo "<pre>$line2</pre>";
echo "<pre>$line3</pre>";
echo "<pre>$line4</pre>";
echo "<pre>$line5</pre>";
?>
Now the issue is that neither it is giving me any error in error_log,nor it is transferring file from one server to another.So basically neither its giving me any error nor its working.As said earlier,I don't know much in php.Can anyone tell me thats what is going on.Any help will be greatly appreciated.
Thanks
Best Regards
Ankit Rauthan