Is there any way to have one server call a开发者_高级运维nd execute a script on another server? I have tried ftp_exec(), but the server does not support it. Here is what I am trying to do.
Server 1 creates and uploads a zip file to Server 2. Server 2 then unzips and extracts the file.
Currently I have scheduled cron jobs at alternating times, one on each server in order to do this. Ideally I would like Server 1 to be able to do everything, sending a message to sever 2 telling it to unzip and extract the uploaded file.
Is it possible to do something on Server 1, like exec(php ftp://user:password@server2/unzip.php)
?
Is it maybe possible using CURL?
FTP = File Transfer Protocol. It's not intended (and should never be used for) remote execution. If you need to trigger a remote script, use HTTP. It's easy enough to do
$stat = file_get_contents('http://example.com/unzip.php');
to invoke the remote PHP script to do the unzipping. If you need authentication on the URL, you can set up a stream or use CURL instead.
Does your sever support ssh or have you the ssh account?
You can run remote commands via ssh.
精彩评论